当前位置: 首页>>代码示例>>C#>>正文


C# ProviderInfo.GetType方法代码示例

本文整理汇总了C#中System.Management.Automation.ProviderInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ProviderInfo.GetType方法的具体用法?C# ProviderInfo.GetType怎么用?C# ProviderInfo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.Automation.ProviderInfo的用法示例。


在下文中一共展示了ProviderInfo.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NewProviderEntry

        /// <summary>
        /// Creates an entry in the providers hashtable for the new provider.
        /// </summary>
        /// 
        /// <param name="provider">
        /// The provider being added.
        /// </param>
        /// 
        /// <exception cref="SessionStateException">
        /// If a provider with the same name and PSSnapIn name already exists.
        /// </exception>
        /// 
        private void NewProviderEntry(ProviderInfo provider)
        {
            bool isDuplicateProvider = false;

            // Add the entry to the list of providers with that name
            if (!Providers.ContainsKey(provider.Name))
            {
                Providers.Add(provider.Name, new List<ProviderInfo>());
            }
            else
            {
                // be sure the same provider from the same PSSnapin doesn't already exist

                List<ProviderInfo> existingProviders = Providers[provider.Name];

                foreach (ProviderInfo existingProvider in existingProviders)
                {
                    //making sure that we are not trying to add the same provider by checking the provider name & type of the new and existing providers.
                    if (string.IsNullOrEmpty(provider.PSSnapInName) && (string.Equals(existingProvider.Name, provider.Name, StringComparison.OrdinalIgnoreCase) &&
                        (existingProvider.GetType().Equals(provider.GetType()))))
                    {
                        isDuplicateProvider = true;
                    }

                    //making sure that we are not trying to add the same provider by checking the PSSnapinName of the new and existing providers.
                    else if (string.Equals(existingProvider.PSSnapInName, provider.PSSnapInName, StringComparison.OrdinalIgnoreCase))
                    {
                        isDuplicateProvider = true;
                    }
                }
            }

            if (!isDuplicateProvider)
            {
                Providers[provider.Name].Add(provider);
            }
        }
开发者ID:40a,项目名称:PowerShell,代码行数:49,代码来源:SessionStateProviderAPIs.cs

示例2: NewProviderEntry

 private void NewProviderEntry(ProviderInfo provider)
 {
     bool flag = false;
     if (!this.Providers.ContainsKey(provider.Name))
     {
         this.Providers.Add(provider.Name, new List<ProviderInfo>());
     }
     else
     {
         List<ProviderInfo> list = this.Providers[provider.Name];
         foreach (ProviderInfo info in list)
         {
             if ((string.IsNullOrEmpty(provider.PSSnapInName) && string.Equals(info.Name, provider.Name, StringComparison.OrdinalIgnoreCase)) && info.GetType().Equals(provider.GetType()))
             {
                 flag = true;
             }
             else if (string.Equals(info.PSSnapInName, provider.PSSnapInName, StringComparison.OrdinalIgnoreCase))
             {
                 flag = true;
             }
         }
     }
     if (!flag)
     {
         this.Providers[provider.Name].Add(provider);
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:SessionStateInternal.cs


注:本文中的System.Management.Automation.ProviderInfo.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。