コード例 #1
0
        public MappingsController()
        {
            var collection = new ServiceCollection();

            collection.AddOptions();
            var Configuration = new ConfigurationBuilder()
#if DEBUG
                                .AddJsonFile("appsettings.Development.json", optional: false, reloadOnChange: true)
#else
                                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
#endif
                                .Build();

            collection.Configure <UserAgentControl>(Configuration.GetSection("UserAgentControl"));
            collection.Configure <dbsettings>(Configuration.GetSection("dbsettings"));
            var services = collection.BuildServiceProvider();

            allowedclients = services.GetService <IOptions <UserAgentControl> >().Value;
            dbsettings     = services.GetService <IOptions <dbsettings> >().Value;
        }
コード例 #2
0
 public MappingsController(IOptions <UserAgentControl> allowedclients)
 {
     this.allowedclients = allowedclients.Value;
 }