Exemplo n.º 1
0
        /// <summary>
        /// Manually defines configuration for a given type of model
        /// </summary>
        /// <typeparam name="T">Model type</typeparam>
        /// <param name="factory">Configuration</param>
        /// <returns>BotDefinitionBuilder</returns>
        public static BotDefinitionBuilder <T> Define <T>(Expression <Func <BotConfigurationBuilder, T> > factory)
        {
            var parser        = new FactoryExpressionParser();
            var configuration = parser.Parse(factory);

            CheckNestedAndCircularDependencies(configuration);

            BuildRules[configuration.ConstructingType] = configuration;

            return(new BotDefinitionBuilder <T>(configuration));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Auto defines configuration for a given type of model
        /// </summary>
        /// <typeparam name="T">Model type</typeparam>
        /// <param name="overrideDefault">Manual configuration overrides</param>
        /// <returns></returns>
        public static BotDefinitionBuilder <T> DefineAuto <T>(Expression <Func <BotConfigurationBuilder, T> >?overrideDefault = null)
        {
            var parser        = new AutoBindingParser();
            var configuration = parser.Parse <T>();

            if (overrideDefault != null)
            {
                var factoryParser  = new FactoryExpressionParser();
                var overrideConfig = factoryParser.Parse(overrideDefault);
                overrideConfig.MergeProperties(configuration);
                configuration = overrideConfig;
            }

            BuildRules[configuration.ConstructingType] = configuration;

            return(new BotDefinitionBuilder <T>(configuration));
        }