예제 #1
0
        private static IConfigProperty <T> GetOrAddProperty <T>([NotNull] IPropertyConfigBase config, [NotNull] String key, [NotNull] IEnumerable <String> sections, [NotNull] Func <IConfigPropertyBase> factory)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (key is null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (sections is null)
            {
                throw new ArgumentNullException(nameof(sections));
            }

            if (factory is null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            String path = ConfigPropertyBase.GetPath(key, sections);

            if (ConfigPropertyObserver.GetOrAddProperty(config, path, factory) is IConfigProperty <T> result)
            {
                return(result);
            }

            throw new ArgumentException(@$ "Config already contains another property with same path '{path}' and different generic type.", nameof(sections));
        }
예제 #2
0
 protected virtual void Dispose(Boolean disposing)
 {
     if (disposing)
     {
         ConfigPropertyObserver.RemoveProperty(this);
     }
 }
예제 #3
0
        private static IConfigProperty <T> GetOrAddProperty <T>([NotNull] IConfigPropertyBase property)
        {
            if (ConfigPropertyObserver.GetOrAddProperty(property) is IConfigProperty <T> result)
            {
                return(result);
            }

            throw new ArgumentException(@$ "Config already contains another property with same path '{property.Path}' and different generic type.", nameof(property));
        }
예제 #4
0
 public Boolean RemoveValue(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(RemoveValue(property.Key, property.Sections));
 }
예제 #5
0
 public Boolean KeyExist(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(KeyExist(property.Key, property.Sections));
 }
예제 #6
0
 public T GetOrSetValue <T>(IReadOnlyConfigProperty <T> property, T value)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(GetOrSetValue(property.Key, value, property.CryptKey, property.Converter, property.Sections));
 }
예제 #7
0
 public T GetOrSetValue <T>(IReadOnlyConfigProperty <T> property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(GetOrSetValue(property, property.DefaultValue));
 }
예제 #8
0
 public void ClearProperties()
 {
     ForEachProperty(ClearProperty);
     ConfigPropertyObserver.ClearProperties(this);
 }
예제 #9
0
 private void ForEachProperty(Action <IReadOnlyConfigPropertyBase> action)
 {
     ConfigPropertyObserver.ForEachProperty(this, action);
 }
예제 #10
0
 public void RemoveProperty(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.RemoveProperty(this, property);
     ClearProperty(property);
 }
예제 #11
0
 public IEnumerable <IReadOnlyConfigPropertyBase>?GetProperties()
 {
     return(ConfigPropertyObserver.GetProperties(this));
 }