コード例 #1
0
        public static IReadOnlyConfigPropertyBase GetOrAddProperty([NotNull] IReadOnlyConfigPropertyBase property)
        {
            if (property is null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            IPropertyConfigBase config = property.Config;

            if (config is null)
            {
                throw new ArgumentException(@"Cannot add property without config", nameof(property));
            }

            String path = property.Path;

            if (path is null)
            {
                throw new ArgumentException(@"Cannot add property without path", nameof(property));
            }

            lock (Properties)
            {
                return(Properties.GetOrAdd(config, CreatePropertyMap).GetOrAdd(path, property));
            }
        }
コード例 #2
0
        public static Boolean IsLinked([NotNull] IReadOnlyConfigPropertyBase property)
        {
            if (property is null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            lock (Properties)
            {
                return(Properties.TryGetValue(property.Config, out IIndexMap <String, IReadOnlyConfigPropertyBase> map) && map.ContainsValue(property));
            }
        }
コード例 #3
0
        public static void ThrowIfPropertyNotLinked([NotNull] IReadOnlyConfigPropertyBase property)
        {
            if (property is null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            if (!IsLinked(property))
            {
                throw new InvalidOperationException("Property not linked to config");
            }
        }
コード例 #4
0
        public static Boolean RemoveProperty([NotNull] IPropertyConfigBase config, [NotNull] IReadOnlyConfigPropertyBase property)
        {
            if (config is null)
            {
                throw new ArgumentNullException(nameof(config));
            }

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

            ThrowIfPropertyNotLinkedTo(config, property);
            return(RemoveProperty(property));
        }
コード例 #5
0
        public static Boolean RemoveProperty(IReadOnlyConfigPropertyBase property)
        {
            if (property is null)
            {
                throw new ArgumentNullException(nameof(property));
            }

            if (property.Config is null)
            {
                throw new ArgumentException(@"Cannot remove property without config", nameof(property));
            }

            lock (Properties)
            {
                if (!Properties.TryGetValue(property.Config, out IIndexMap <String, IReadOnlyConfigPropertyBase> dictionary))
                {
                    return(false);
                }

                return(dictionary is not null && dictionary.Remove(property.Path));
            }
        }
コード例 #6
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 public Boolean RemoveValue(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(RemoveValue(property.Key, property.Sections));
 }
コード例 #7
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 public Boolean KeyExist(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinked(property);
     return(KeyExist(property.Key, property.Sections));
 }
コード例 #8
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 public void RemoveProperty(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.RemoveProperty(this, property);
     ClearProperty(property);
 }
コード例 #9
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 private static void ClearProperty(IReadOnlyConfigPropertyBase property)
 {
     (property as IConfigPropertyBase)?.Dispose();
 }
コード例 #10
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 private static void ResetProperty(IReadOnlyConfigPropertyBase property)
 {
     (property as IConfigPropertyBase)?.Reset();
 }
コード例 #11
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 private static void SaveProperty(IReadOnlyConfigPropertyBase property)
 {
     (property as IConfigPropertyBase)?.Save();
 }
コード例 #12
0
ファイル: Property.cs プロジェクト: Rain0Ash/NetExtender
 private static void ReadProperty(IReadOnlyConfigPropertyBase property)
 {
     property?.Read();
 }
コード例 #13
0
 public Boolean RemoveValue(IReadOnlyConfigPropertyBase property)
 {
     return(Config.RemoveValue(property));
 }
コード例 #14
0
 public Boolean KeyExist(IReadOnlyConfigPropertyBase property)
 {
     return(Config.KeyExist(property));
 }
コード例 #15
0
 public void RemoveProperty(IReadOnlyConfigPropertyBase property)
 {
     ConfigPropertyObserver.ThrowIfPropertyNotLinkedTo(this, property);
     ConfigPropertyObserver.RemoveProperty(property);
     ClearProperty(property);
 }