示例#1
0
        internal ServiceLocatorConfiguration LoadConfigSource()
        {
            string configFilePath;

            if (Path.IsPathRooted(this.ConfigFilePath))
            {
                configFilePath = this.ConfigFilePath;
            }
            else
            {
                string configFileFolder = Path.GetDirectoryName(this.ElementInformation.Source);

                configFilePath = Path.Combine(configFileFolder, this.ConfigFilePath);
            }

            ServiceLocatorConfiguration result = ConfigurationHelpers.Load <ServiceLocatorConfiguration>(ServiceLocatorConfiguration.AppSectionName, configFilePath);

            if (result == null)
            {
                throw new ConfigurationErrorsException(
                          "Configuration source file '{0}' was not found.".FormatInvariant(this.ConfigFilePath),
                          this.ElementInformation.Source,
                          this.ElementInformation.LineNumber);
            }

            return(result);
        }
        internal void AddConfigSources(SourcesConfigurationCollection configSources)
        {
            foreach (SourceConfigurationElement configSource in configSources)
            {
                ServiceLocatorConfiguration configuration = configSource.LoadConfigSource();

                this.AddContractImplementations(configuration.Services.contractImplementations.Values.SelectMany(v => v));
            }
        }