Example #1
0
        public static IComponentBuilder Configure <TOptions>(this IComponentBuilder builder, IConfiguration config, string @namespace)
            where TOptions : class, new()
        {
            builder.AddOptions <TOptions>();
            var services = builder.Container;

            services
            .RegisterInstance(new ConfigurationChangeTokenSource <TOptions>(@namespace, config))
            .SingleInstance().As <IOptionsChangeTokenSource <TOptions> >();
            services
            .RegisterInstance(new NamedConfigureFromConfigurationOptions <TOptions>(@namespace, config))
            .SingleInstance()
            .As <IConfigureNamedOptions <TOptions> >()
            .As <IConfigureOptions <TOptions> >()
            .As <IConfigureNamedOptions <TOptions> >();
            return(builder);
        }