Пример #1
0
        private void onLoaded(IIdentifiedSource settings)
        {
            var copy = Loaded;

            if (copy != null)
            {
                copy(this, new LoadedEventArgs(settings));
            }
        }
        public SettingsLoader LoadSettings(IIdentifiedSource setting)
        {
            if (CheckLoaded(setting))
                return this;

            _settings.Add(setting);
            OnLoaded(setting);
            IncludeSettings(setting);
            return this;
        }
Пример #3
0
        public Result LoadSettings(IIdentifiedSource setting, IDeserializer deserializer, string searchPath = null)
        {
            if (searchPath == null)
            {
                var rpo = setting as IFilePathOwner;
                if (rpo != null)
                {
                    searchPath = rpo.Path;
                }
            }

            var context = new Context(deserializer, searchPath);

            context.Sources.Add(setting);
            onLoaded(setting);
            context.CheckLoaded(setting);

            return(new Result(
                       new DefaultConfigNodeProvider(scanInclude(setting, context)),
                       context.Sources.AsReadOnly()));
        }
Пример #4
0
 public Result LoadSettings(IIdentifiedSource setting, string searchPath)
 {
     return(LoadSettings(setting, DefaultDeserializer.Instance, searchPath));
 }
Пример #5
0
 public Result LoadSettings(IIdentifiedSource setting)
 {
     return(LoadSettings(setting, DefaultDeserializer.Instance));
 }
Пример #6
0
            public bool CheckLoaded(IIdentifiedSource settings)
            {
                var key = new IdentityKey(settings.GetType(), settings.Identity);

                return(!_loaded.Add(key));
            }
Пример #7
0
 public LoadedEventArgs(IIdentifiedSource settings)
 {
     Settings = settings;
 }
        private void IncludeSettings(IIdentifiedSource source)
        {
            var includeRoot = source.TryFirst<ICfgNode>("Include", false);
            if(includeRoot == null)
                return;

            foreach (var incNode in includeRoot.GetNodes())
            {
                if (NameComparer.Equals(incNode.Key, "FinalSearch"))
                    continue;

                ISettingsFactory factory;
                if(!_tagMap.TryGetValue(incNode.Key, out factory))
                    throw new InvalidOperationException(string.Format("unknown include type '{0}'", incNode.Key));

                foreach (var incSetting in factory.CreateSettings(source, incNode.Value))
                    LoadSettings(incSetting);
            }
        }
 private bool CheckLoaded(IIdentifiedSource settings)
 {
     var key = new IdentityKey(settings.GetType(), settings.Identity);
     return !_loaded.Add(key);
 }
Пример #10
0
 private void OnLoaded(IIdentifiedSource settings)
 {
     var copy = Loaded;
     if (copy != null)
         copy(this, new LoadedEventArgs(settings));
 }
 public LoadedEventArgs(IIdentifiedSource settings)
 {
     Settings = settings;
 }