IDictionary LoadProviders(ITypeResolutionService resolution) { if (Configuration.Arguments == null) { return(new System.Collections.Specialized.HybridDictionary(0)); } try { // At most we will have a provider for each argument. IDictionary providers = new System.Collections.Specialized.HybridDictionary(Configuration.Arguments.Length); monitoredArguments = new System.Collections.Specialized.HybridDictionary(Configuration.Arguments.Length); bool hasmonitors = false; IValueInfoService mdservice = GetService <IValueInfoService>(true); // Setup monitoring for dependent argument changes. foreach (Config.Argument argument in Configuration.Arguments) { if (argument.ValueProvider != null) { IValueProvider provider = GetInstance <IValueProvider>(resolution, argument.ValueProvider.Type); // Initialize the provider by passing the configuration for the argument it provides values to. provider.Initialize(mdservice.GetInfo(argument.Name)); if (provider is IAttributesConfigurable) { Configure((IAttributesConfigurable)provider, argument.ValueProvider.AnyAttr); } providers.Add(argument.Name, provider); // Site the provider so it can access all services. if (provider is IComponent) { Add((IComponent)provider); } // Add to the argument-indexed list of providers monitoring arguments. if (argument.ValueProvider.MonitorArgument != null) { hasmonitors = true; foreach (Config.MonitorArgument monitored in argument.ValueProvider.MonitorArgument) { // Throw if the value provider is monitoring the same argument it's attached to. if (monitored.Name == argument.Name) { throw new System.Configuration.ConfigurationException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.Recipe_ArgumentCantMonitorItself, argument.ValueProvider.Type, argument.Name)); } ArrayList monitoringproviders = (ArrayList)monitoredArguments[monitored.Name]; if (monitoringproviders == null) { monitoringproviders = new ArrayList(); monitoredArguments[monitored.Name] = monitoringproviders; } monitoringproviders.Add(provider); } } } } if (providers.Count != 0 && hasmonitors) { // Attach to change event if monitoring arguments. IComponentChangeService changes = GetService <IComponentChangeService>(true); changes.ComponentChanged += new ComponentChangedEventHandler(OnArgumentChanged); } return(providers); } catch (Exception ex) { throw new ValueProviderException(this.Configuration.Name, Properties.Resources.Recipe_ValueProviderLoadFailed, ex); } }