Exemplo n.º 1
0
        /// <summary>
        /// Gets ConfigurationPropertyModelBuilder for property with option
        /// Overides existing configuration from property
        /// </summary>
        /// <typeparam name="TModel">Source model type</typeparam>
        /// <typeparam name="TOption">Option type</typeparam>
        /// <typeparam name="TConfigurationSet">ConfigurationSet to provide available options</typeparam>
        /// <typeparam name="TValue">Property Type</typeparam>
        /// <param name="source">model with property</param>
        /// <param name="expression">property selector</param>
        /// <param name="optionProvider">Option provider</param>
        /// <returns>ConfigurationPropertyWithOptionBuilder for selected property</returns>
        public static ConfigurationPropertyWithOptionValueBuilder PropertyWithOptionValue <TModel, TValue, TOption, TConfigurationSet>(this IModelWithProperties <TModel> source, Expression <Func <TModel, TValue> > expression, IConfigurationSetOptionValueProvider <TConfigurationSet, TOption, TValue> optionProvider) where TConfigurationSet : ConfigurationSet
        {
            var propertyName = ExpressionHelper.GetPropertyNameFromExpression(expression);
            var model        = new ConfigurationPropertyWithOptionValueModelDefinition <TConfigurationSet, TOption, TValue>(optionProvider, propertyName, typeof(TModel));

            source.ConfigurationProperties[propertyName] = model;
            return(new ConfigurationPropertyWithOptionValueBuilder(model));
        }
 /// <summary>
 /// Initializes ConfigurationPropertyWithOptionBuilder for given ConfigurationPropertyModel
 /// </summary>
 /// <param name="model">ConfigurationPropertyModel to be modified by ConfigurationPropertyModelBuilder</param>
 internal ConfigurationPropertyWithOptionValueBuilder(ConfigurationPropertyWithOptionValueModelDefinition model) : base(model)
 {
 }