コード例 #1
0
ファイル: Startup.cs プロジェクト: guy-lud/CrawlerDemo
        public void ConfigureContainer(Container container)
        {
            var config     = new ConfigBuilder();
            var collection = new AssemblyCollection()
                             .AddPublicTypesAssemblies(GetType().GetTypeInfo().Assembly,
                                                       typeof(Ref).Assembly,
                                                       typeof(DomainRef).Assembly);

            config.Add(new ExistAll.SimpleConfig.Binders.ConfigurationBinder(Configuration));

            var settings = config.Build(collection.Assemblies, new ConfigOptions()
            {
                ConfigSuffix = "Settings"
            });

            foreach (var setting in settings)
            {
                container.RegisterSingleton(setting.Key, setting.Value);
            }

            container.RegisterSingleton <ISystemClock, SystemClock>();
            container.RegisterSingleton <ISiteCrawler, HttpSiteCrawler>();
            container.RegisterDecorator <ISiteCrawler, CacheHttpSiteCrawler>();
            container.RegisterSingleton <ISiteRepository, SiteRepository>();
            container.RegisterSingleton <ICrawlerSiteRequestValidator, SiteInfoRequestValidator>();
        }