本文整理汇总了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);
}
}
示例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);
}
}