コード例 #1
0
        private object GetConfigPropertyValueFromInput(JObject source, ConfigurationPropertyModelBase propertyModel)
        {
            var propertyValue = source.GetValue(propertyModel.ConfigurationPropertyName.ToLowerCamelCase());

            if (propertyModel is ConfigurationPrimitivePropertyModel primativeModel && primativeModel.ValidationRules.IsRequired && propertyValue.Type == JTokenType.Null)
            {
                throw new ConfigModelParsingException($"{propertyModel.PropertyDisplayName} is Required");
            }
            var result = source.GetValue(propertyModel.ConfigurationPropertyName.ToLowerCamelCase())?.ToObject(propertyModel.PropertyType);

            return(result);
        }
コード例 #2
0
        private ConfigurationPropertyPayload BuildProperty(ConfigurationPropertyModelBase value, ConfigurationIdentity configIdentity, IEnumerable <ConfigurationSet> requiredConfigurationSets)
        {
            switch (value)
            {
            case ConfigurationPrimitivePropertyModel input:
                return(BuildProperty(input));

            case IOptionPropertyDefinition input:
                return(BuildProperty(input, configIdentity, requiredConfigurationSets));

            case ConfigurationCollectionPropertyDefinition input:
                return(BuildProperty(input, configIdentity, requiredConfigurationSets));

            default:
                throw new InvalidOperationException($"Could not handle ConfigurationPropertyModelBase of type {value.GetType().Name}");
            }
        }
コード例 #3
0
        private ConfigurationPropertyPayload BuildProperty(ConfigurationPropertyModelBase value)
        {
            switch (value)
            {
            case ConfigurationPrimitivePropertyModel input:
                return(BuildProperty(input));

            case ConfigurationPropertyWithOptionsModelDefinition input:
                return(BuildProperty(input));

            case ConfigurationCollectionPropertyDefinition input:
                return(BuildProperty(input));

            default:
                throw new InvalidOperationException($"Could not handle ConfigurationPropertyModelBase of type {value.GetType().Name}");
            }
        }
コード例 #4
0
        public string GetPropertyType(ConfigurationPropertyModelBase propertyModel)
        {
            switch (propertyModel)
            {
            case ConfigurationPrimitivePropertyModel input:
                return(GetPropertyType(input));

            case ConfigurationPropertyWithOptionsModelDefinition input:
                return(GetPropertyType(input));

            case ConfigurationCollectionPropertyDefinition input:
                return(GetPropertyType(input));

            default:
                throw new InvalidOperationException($"Could not handle ConfigurationPropertyModelBase of type {propertyModel.GetType().Name}");
            }
        }
コード例 #5
0
        private void UpdateOptions(object source, ConfigurationPropertyModelBase model, IEnumerable <ConfigurationSet> configurationSets, ConfigurationIdentity configIdentity)
        {
            switch (model)
            {
            case ConfigurationClassCollectionPropertyDefinition collectionProperty:
                UpdateOptions(source, collectionProperty, configurationSets, configIdentity);
                break;

            case IMultipleOptionPropertyDefinition optionFromSetProperty:
                UpdateOptions(source, optionFromSetProperty, configurationSets, configIdentity);
                break;

            case IOptionPropertyDefinition optionProperty:
                UpdateOptions(source, optionProperty, configurationSets, configIdentity);
                break;

            default:
                break;
            }
        }
コード例 #6
0
        private void UpdateOptions(object source, ConfigurationPropertyModelBase model)
        {
            switch (model)
            {
            case ConfigurationPropertyWithMultipleOptionsModelDefinition optionsProperty:
                UpdateOptions(source, optionsProperty);
                break;

            case ConfigurationPropertyWithOptionsModelDefinition optionProperty:
                UpdateOptions(source, optionProperty);
                break;

            case ConfigurationCollectionPropertyDefinition collectionProperty:
                UpdateOptions(source, collectionProperty);
                break;

            default:
                break;
            }
        }
コード例 #7
0
        private object GetPropertyValueFromConfig(string propertyType, object source, ConfigurationPropertyModelBase propertyModel)
        {
            switch (propertyType)
            {
            case ConfigurationPropertyType.Option:
                return(GetPropertyValue(source, (ConfigurationPropertyWithOptionsModelDefinition)propertyModel));

            case ConfigurationPropertyType.MultipleOption:
                return(GetPropertyValue(source, (ConfigurationPropertyWithMultipleOptionsModelDefinition)propertyModel));

            case ConfigurationPropertyType.Collection:
                return(GetPropertyValue(source, (ConfigurationCollectionPropertyDefinition)propertyModel));

            default:
                return(propertyModel.GetPropertyValue(source));
            }
        }
コード例 #8
0
        private object GetConfigPropertyValueFromInput(JObject source, ConfigurationPropertyModelBase propertyModel)
        {
            var result = source.GetValue(propertyModel.ConfigurationPropertyName.ToLowerCamelCase()).ToObject(propertyModel.PropertyType);

            return(result);
        }
コード例 #9
0
        private object GetConfigPropertyValueFromInput(string propertyType, JObject source, ConfigurationPropertyModelBase propertyModel, ConfigurationIdentity configIdentity, IEnumerable <ConfigurationSet> requiredConfigurationSets)
        {
            switch (propertyType)
            {
            case ConfigurationPropertyType.Option:
                return(GetOptionConfigPropertyValueFromInput(source, (IOptionPropertyDefinition)propertyModel, configIdentity, requiredConfigurationSets));

            case ConfigurationPropertyType.MultipleOption:
                return(GetConfigPropertyValueFromInput(source, (IMultipleOptionPropertyDefinition)propertyModel, configIdentity, requiredConfigurationSets));

            case ConfigurationPropertyType.Collection:
                return(GetConfigPropertyValueFromInput(source, (ConfigurationCollectionPropertyDefinition)propertyModel, configIdentity, requiredConfigurationSets));

            default:
                return(GetConfigPropertyValueFromInput(source, propertyModel));
            }
        }