本文整理汇总了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);
}
示例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);
}
}
示例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();
}