Exemple #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));
        }
Exemple #2
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));
        }