Example #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>
        /// <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 ConfigurationPropertyWithOptionBuilder PropertyWithOption <TModel, TOption, TConfigurationSet>(this IModelWithProperties <TModel> source, Expression <Func <TModel, TOption> > expression, IConfigurationSetOptionProvider <TConfigurationSet, TOption> optionProvider) where TConfigurationSet : ConfigurationSet
        {
            var propertyName = ExpressionHelper.GetPropertyNameFromExpression(expression);
            var model        = new ConfigurationPropertyWithOptionModelDefinition <TConfigurationSet, TOption>(optionProvider, propertyName, typeof(TModel));

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