当前位置: 首页>>代码示例>>C#>>正文


C# Container.RegisterAutoWiredTypes方法代码示例

本文整理汇总了C#中Funq.Container.RegisterAutoWiredTypes方法的典型用法代码示例。如果您正苦于以下问题:C# Container.RegisterAutoWiredTypes方法的具体用法?C# Container.RegisterAutoWiredTypes怎么用?C# Container.RegisterAutoWiredTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Funq.Container的用法示例。


在下文中一共展示了Container.RegisterAutoWiredTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FunqControllerFactory

        public FunqControllerFactory(Container container)
        {
            this.funqBuilder = new ContainerResolveCache(container);

            // Also register all the controller types as transient
            var controllerTypes =
                (from type in Assembly.GetCallingAssembly().GetTypes()
                 where typeof(IController).IsAssignableFrom(type)
                 select type).ToList();

            container.RegisterAutoWiredTypes(controllerTypes);
        }
开发者ID:niemyjski,项目名称:ServiceStack,代码行数:12,代码来源:FunqControllerFactory.cs

示例2: FunqControllerFactory

        /// <summary>
        /// Initializes a new instance of the <see cref="FunqControllerFactory" /> class.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="assemblies">The assemblies to reflect for IController discovery.</param>
        public FunqControllerFactory(Container container, params Assembly[] assemblies)
		{
			this.funqBuilder = new ContainerResolveCache(container);

            // aggregate the local and external assemblies for processing (unless ignored)
            IEnumerable<Assembly> targetAssemblies = assemblies.Concat(new[] { Assembly.GetCallingAssembly() });

            foreach (var assembly in targetAssemblies)
            {
                // Also register all the controller types as transient
                var controllerTypes =
                    (from type in assembly.GetTypes()
                     where typeof(IController).IsAssignableFrom(type)
                     select type).ToList();

                container.RegisterAutoWiredTypes(controllerTypes);
            }
		}
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:23,代码来源:FunqControllerFactory.cs

示例3: Configure

        public override void Configure(Container container)
        {
            //Plugins.RemoveAll(x => x is MetadataFeature);
            Plugins.Add(new CorsFeature());
            Plugins.Add(new SwaggerFeature());
            Plugins.Add(new ValidationFeature());
            Plugins.Add(new PostmanFeature());

            var config = new AppConfig();

            config.ReadWriteApiKeys.AddRange(ConfigurationManager.AppSettings["apiKeys"].Split(new[] {','}));

            container.Register(config);

            GlobalRequestFilters.Add((req, res, requestDto) =>
            {
                if (requestDto.GetType() != typeof (CreateCrawler) &&
                    req.Verb.ContainsAny(new[] {"DELETE", "PUT", "POST"}))
                {
                    var keyValidator = new ApiKeyAttribute();
                    keyValidator.Execute(req, res, requestDto);
                }
            });

            SetConfig(new HostConfig
            {
                DefaultRedirectPath = "/swagger-ui/"
            });

            container.RegisterAutoWiredAs<UriRequestRunner, IScraperRequestRunner>();
            container.RegisterAutoWiredAs<WebScraper, IScraper>();
            container.RegisterAutoWiredAs<CrawlWebRunner, ICrawlRunner>();

            container.RegisterAutoWiredTypes(new[]
            {typeof (CrawlerValidator), typeof (LeagueEngine), typeof (LeagueServices)});

            container.RegisterValidators(typeof(CreateSeasonValidator).Assembly);

            //container.RegisterAutoWired<GameEngine>().ReusedWithin(ReuseScope.Container);

            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/leaguedata.sqlite"),
                    SqliteDialect.Provider));

            //container.Register<IDbConnectionFactory>(
            //    new OrmLiteConnectionFactory(
            //    "Server=127.0.0.1;Port=5432;User Id=postgres;Password=test123;Database=testDb;Pooling=true;MinPoolSize=0;MaxPoolSize=200",
            //    PostgreSqlDialect.Provider));

            using (var db = container.Resolve<IDbConnectionFactory>().Open())
            {
                db.CreateTableIfNotExists<Season>();
                db.CreateTableIfNotExists<Division>();
                db.CreateTableIfNotExists<Server>();
                db.CreateTableIfNotExists<Crawler>();
                db.CreateTableIfNotExists<Participant>();
                db.CreateTableIfNotExists<Game>();
                db.CreateTableIfNotExists<Rune>();
            }

            OrmLiteConfig.InsertFilter = (dbCmd, row) =>
            {
                var auditRow = row as IAudit;
                if (auditRow != null)
                    auditRow.CreatedDate = auditRow.ModifiedDate = DateTime.UtcNow;
            };

            OrmLiteConfig.UpdateFilter = (dbCmd, row) =>
            {
                var auditRow = row as IAudit;
                if (auditRow != null)
                    auditRow.ModifiedDate = DateTime.UtcNow;
            };

            container.Resolve<LeagueEngine>().Start();
        }
开发者ID:jrmitch120,项目名称:CrawlLeague,代码行数:76,代码来源:Global.asax.cs


注:本文中的Funq.Container.RegisterAutoWiredTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。