/// <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); } }
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); } }