Пример #1
0
 /// <summary>
 /// overridden to declare how the configuration set sets up the information required to build, configure and validate the configurations.
 /// </summary>
 /// <param name="modelBuilder">ConfigurationSetModelBuilder used to construct ConfigurationSetModel</param>
 protected virtual void OnModelCreation(ConfigurationSetModelBuilder <T> modelBuilder)
 {
     foreach (var propertyInfo in typeof(T).GetProperties().Where(info => info.PropertyType.IsConstructedGenericType && info.PropertyType.GetGenericTypeDefinition() == typeof(Config <>)))
     {
         modelBuilder.AddConfig(propertyInfo.Name, propertyInfo.PropertyType.GenericTypeArguments[0]);
     }
 }
Пример #2
0
        /// <summary>
        /// Builds the ConfigurationSetModel that contains the information required to build, configure and validate the configuration
        /// </summary>
        /// <returns>Initialized ConfigurationSetModel</returns>
        public ConfigurationSetModel BuildConfigurationSetModel()
        {
            var builder = new ConfigurationSetModelBuilder <T>(Name ?? this.GetType().Name, Description);

            OnModelCreation(builder);
            return(builder.Build());
        }
 /// <summary>
 /// Gets ConfigurationModelBuilder for Options
 /// </summary>
 /// <typeparam name="TConfiguration">Option Type</typeparam>
 /// <typeparam name="TConfigurationSet">ConfigurationSet type</typeparam>
 /// <param name="source">ConfigurationSetModelBuilder</param>
 /// <param name="expression">Path to Options</param>
 /// <param name="keySelector">Option Key Selector</param>
 /// <param name="descriptionSelector">Option Description Selector</param>
 /// <param name="optionProvider">Option provider</param>
 /// <returns>ConfigurationModelBuilder for Options</returns>
 public static ConfigurationModelBuilder <TConfiguration, TConfigurationSet> Options <TConfiguration, TConfigurationSet>(this ConfigurationSetModelBuilder <TConfigurationSet> source, Expression <Func <TConfigurationSet, OptionSet <TConfiguration> > > expression, Func <TConfiguration, int> keySelector, Func <TConfiguration, object> descriptionSelector, Func <ConfigurationIdentity, IEnumerable <TConfiguration> > optionProvider)
     where TConfiguration : class, new()
     where TConfigurationSet : ConfigurationSet <TConfigurationSet>, new()
 {
     return(source.Options(expression, keySelector, descriptionSelector, optionProvider, typeof(TConfiguration).Name, string.Empty));
 }
 /// <summary>
 /// Gets ConfigurationModelBuilder for Options
 /// </summary>
 /// <typeparam name="TConfiguration">Option Type</typeparam>
 /// <typeparam name="TConfigurationSet">ConfigurationSet type</typeparam>
 /// <param name="source">ConfigurationSetModelBuilder</param>
 /// <param name="expression">Path to Options</param>
 /// <param name="keySelector">Option Key Selector</param>
 /// <param name="descriptionSelector">Option Description Selector</param>
 /// <param name="optionProvider">Option provider</param>
 /// <param name="displayName">Display name for the config</param>
 /// <returns>ConfigurationModelBuilder for Options</returns>
 public static ConfigurationModelBuilder <TConfiguration, TConfigurationSet> Options <TConfiguration, TConfigurationSet>(this ConfigurationSetModelBuilder <TConfigurationSet> source, Expression <Func <TConfigurationSet, OptionSet <TConfiguration> > > expression, Func <TConfiguration, int> keySelector, Func <TConfiguration, object> descriptionSelector, Func <IEnumerable <TConfiguration> > optionProvider, string displayName)
     where TConfiguration : class, new()
     where TConfigurationSet : ConfigurationSet <TConfigurationSet>, new()
 {
     return(source.Options(expression, option => keySelector(option).ToString(), descriptionSelector, optionProvider, displayName, string.Empty));
 }
 /// <summary>
 /// Gets ConfigurationModelBuilder for type
 /// </summary>
 /// <typeparam name="TConfiguration">Configuration type</typeparam>
 /// <typeparam name="TConfigurationSet">ConfigurationSet type</typeparam>
 /// <param name="source">ConfigurationSetModelBuilder</param>
 /// <param name="expression">Path to config</param>
 /// <param name="displayName">Display name for the config</param>
 /// <returns>ConfigurationModelBuilder for type</returns>
 public static ConfigurationModelBuilder <TConfiguration, TConfigurationSet> Config <TConfiguration, TConfigurationSet>(this ConfigurationSetModelBuilder <TConfigurationSet> source, Expression <Func <TConfigurationSet, Config <TConfiguration> > > expression, string displayName)
     where TConfiguration : class, new()
     where TConfigurationSet : ConfigurationSet <TConfigurationSet>, new()
 {
     return(source.Config(expression, displayName, string.Empty));
 }
Пример #6
0
 /// <summary>
 /// Gets ConfigurationModelBuilder for Options
 /// </summary>
 /// <typeparam name="TConfiguration">Option Type</typeparam>
 /// <typeparam name="TConfigurationSet">ConfigurationSet type</typeparam>
 /// <param name="source">ConfigurationSetModelBuilder</param>
 /// <param name="expression">Path to Options</param>
 /// <param name="keySelector">Option Key Selector</param>
 /// <param name="descriptionSelector">Option Description Selector</param>
 /// <returns>ConfigurationModelBuilder for Options</returns>
 public static ConfigurationModelBuilder <TConfiguration, TConfigurationSet> Options <TConfiguration, TConfigurationSet>(this ConfigurationSetModelBuilder <TConfigurationSet> source, Expression <Func <TConfigurationSet, OptionSet <TConfiguration> > > expression, Expression <Func <TConfiguration, long> > keySelector, Func <TConfiguration, object> descriptionSelector)
     where TConfiguration : class, new()
     where TConfigurationSet : ConfigurationSet <TConfigurationSet>, new()
 {
     return(source.Options(expression, keySelector, descriptionSelector, typeof(TConfiguration).Name, string.Empty));
 }