Пример #1
0
        protected virtual IConfigurationManager CreateManager(Dictionary <int, IConfigurationSource> sources)
        {
            ConfigurationManagerConfig managerConfig = ConfigurationManagers.NewConfigBuilder().SetName("test")
                                                       .AddSources(sources).Build();

            Console.WriteLine("manager config: " + managerConfig + "\n");
            return(ConfigurationManagers.NewManager(managerConfig));
        }
Пример #2
0
        public DefaultConfigurationManager(ConfigurationManagerConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config is null");
            }

            _config = config;

            _sortedSources = ImmutableSortedDictionary.CreateRange(PriorityComparator, _config.Sources);
            _sortedSources.Values.ToList().ForEach(s => s.OnChange += OnSourceChange);

            _properties     = new ConcurrentDictionary <object, IProperty>();
            _propertiesLock = new object();

            _genericGetPropertyValueMethod = GetType().GetMethods().Where(methodInfo =>
                                                                          methodInfo.Name == "GetPropertyValue" &&
                                                                          methodInfo.IsGenericMethod && methodInfo.GetGenericArguments().Length == 2 &&
                                                                          methodInfo.GetParameters().Count() == 1
                                                                          ).Single();

            Logger.Info("Configuration Manager created: {0}", ToString());
        }