本文整理汇总了C#中Funq.RegisterAutoWired方法的典型用法代码示例。如果您正苦于以下问题:C# Funq.RegisterAutoWired方法的具体用法?C# Funq.RegisterAutoWired怎么用?C# Funq.RegisterAutoWired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq
的用法示例。
在下文中一共展示了Funq.RegisterAutoWired方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public override void Configure(Funq.Container container)
{
container.Register<IDbConnectionFactory>(
c =>
new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(),
SqliteDialect.Provider)
{
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
container.RegisterAutoWired<JournalService>();
container.RegisterAutoWired<SessionService>();
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.DropAndCreateTable<Journal>();
db.DropAndCreateTable<Session>();
db.DropAndCreateTable<Task>();
db.DropAndCreateTable<JournalNote>();
db.DropAndCreateTable<SessionNote>();
//Seed Lists
db.InsertAll(SeedData.JournalSeed);
db.InsertAll(SeedData.JournalNoteSeed);
db.InsertAll(SeedData.SessionSeed);
db.InsertAll(SeedData.TaskSeed);
db.InsertAll(SeedData.SessionNoteSeed);
}
}
示例2: Configure
public override void Configure(Funq.Container container)
{
container.RegisterAutoWired<PlayersRepository>();
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(AppHost).Assembly);
}
示例3: RegisterDependencies
private void RegisterDependencies(Funq.Container container)
{
var ormLiteConnectionFactory =
new OrmLiteConnectionFactory(System.IO.Path.GetFullPath("~/../../../App_Data/data.db"), SqliteDialect.Provider);
container.Register<IDbConnectionFactory>(ormLiteConnectionFactory);
container.RegisterAutoWired<CommandRepository>();
}
示例4: Configure
public override void Configure(Funq.Container container)
{
//var dbConnectionFactory = new OrmLiteConnectionFactory
// (WebConfigurationManager.ConnectionStrings["snomed"].ToString(),
// SqlServerOrmLiteDialectProvider.Instance);
//container.Register<IDbConnectionFactory>(dbConnectionFactory);
//using (var db = dbConnectionFactory.Open())
//{
// db.CreateTable<Concept>();
//}
container.RegisterAutoWired<DataRepository>();
}
示例5: Configure
public override void Configure(Funq.Container container)
{
Plugins.Add(new CorsFeature());
//GlobalRequestFilters.Add((httpReq, httpRes, requestDto) =>
//{
// if (httpReq.HttpMethod == "OPTIONS")
// {
// httpRes.EndRequest();
// }
//});
var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/wordData.txt"), SqliteDialect.Provider);
container.Register<IDbConnectionFactory>(dbConnectionFactory);
container.RegisterAutoWired<DataRepository>();
}
示例6: Configure
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
JsConfig.EmitCamelCaseNames = true;
//Register Typed Config some services might need to access
var appConfig = new AppConfig(new AppSettings());
//appconfig will contain properties from web.config
container.Register(appConfig);
//inform api that this will be using BasicAuth to authenticate/authorize users
Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] { new BasicAuthProvider(), }));
//add registration functionality (user will need admin role to access this)
Plugins.Add(new RegistrationFeature());
//add validation using fluent validation package
Plugins.Add(new ValidationFeature());
//register service to validate
container.RegisterValidators(typeof(AwardService).Assembly);
if (appConfig.UseRedis){
//setup cache client to user redis
container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(appConfig.RedisReadWriteHosts.ToArray()));
container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
//setup redis for authentication repository
container.Register<IUserAuthRepository>(c => new RedisAuthRepository(c.Resolve<IRedisClientsManager>()));
}
else
{
//setup cache client to be InMemory
container.Register<ICacheClient>(c => new MemoryCacheClient());
//setup authentication repository to be InMemory
container.Register<IUserAuthRepository>(c => new InMemoryAuthRepository());
}
//seed possible users
SeedUsers(container.Resolve<IUserAuthRepository>());
//register any repository classes here
container.RegisterAutoWired<AwardRepository>();
}
示例7: Configure
public override void Configure(Funq.Container container)
{
Plugins.Add(new CorsFeature());
RequestFilters.Add((httpReq, httpRes, requestDto) =>
{
//Handles Request and closes Responses after emitting global HTTP Headers
if (httpReq.HttpMethod == "OPTIONS")
httpRes.EndRequest();
});
var dbConnectionFactory =
new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookData.txt"),
SqliteDialect.Provider);
container.Register<IDbConnectionFactory>(dbConnectionFactory);
container.RegisterAutoWired<DataRepository>();
}
开发者ID:robertohernando,项目名称:Building-Web-Applications-with-Open-Source-Software-on-Windows,代码行数:15,代码来源:Global.asax.cs
示例8: Configure
public override void Configure(Funq.Container container)
{
Plugins.Add(new CorsFeature());
PreRequestFilters.Add((httpReq, httpRes) =>
{
if (httpReq.Verb == "OPTIONS")
httpRes.EndRequest();
});
var dbConnectionFactory =
new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/bookdata.txt"),
SqliteDialect.Provider);
container.Register<IDbConnectionFactory>(dbConnectionFactory);
container.RegisterAutoWired<DataRepository>();
}
示例9: Configure
public override void Configure(Funq.Container container)
{
container.RegisterAutoWired<DataRepository>();
Plugins.Add(new CorsFeature(
allowOriginWhitelist: new[] { "http://localhost:36085", "http://localhost", "http://hwl59427d", "http://edwaitingtimes-test", "http://edwaitingtimes" },
allowedHeaders: "Content-Type",
allowCredentials: true
));
// Globally enable CORS for all OPTION requests
this.PreRequestFilters.Add((httpReq, httpRes) =>
{
//Handles Request and closes Responses after emitting global HTTP Headers
if (httpReq.Verb == "OPTIONS")
httpRes.EndRequest();
});
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
}
示例10: Configure
public override void Configure(Funq.Container container)
{
//to inject third-party IoC (for example for NInject use SrviceStack.ContainerAdapter.NInject)
//IKernel kernel=new StandartKernel();
//kernel.Bind<TrackedDataRepository>().ToSelf();
//container.Adapter=new NinjectContainerAdapter(kernel); -> provide a adapter layer for NInject to use in Funq
Plugins.Add(new AuthFeature(() => new AuthUserSession(),
new IAuthProvider[] { new BasicAuthProvider() ,
new TwitterAuthProvider(new AppSettings())}));
Plugins.Add(new RegistrationFeature());
//register validators
Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof(Common.Entry).Assembly, typeof(EntryService).Assembly);
//request logs
Plugins.Add(new RequestLogsFeature()); // added ability to view request via http:/..../requestlogs
//cache registration
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
//container.Register<ICacheClient>(r => (ICacheClient)r.Resolve<IRedisClientsManager>().GetCacheClient());
var userRepository = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepository);
string hash;
string salt;
new SaltedHash().GetHashAndSaltString("password1", out hash, out salt);
userRepository.CreateUserAuth(new UserAuth()
{
Id = 1,
DisplayName = "Joe user",
Email = "[email protected]",
UserName = "jsuser",
LastName = "jname",
PasswordHash = hash,
Salt = salt,
Roles = new List<string> { RoleNames.Admin }//,
//Permissions = new List<string> { "GetStatus", "AddStatus" }
}, "password1");
//automatically inject in all public properties
container.RegisterAutoWired<TrackedDataRepository>().ReusedWithin(Funq.ReuseScope.Default);
container.RegisterAutoWired<TrackedDataRepository2>().ReusedWithin(Funq.ReuseScope.Default);
var dbConFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/data.txt"), SqliteDialect.Provider)
{
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
};
container.Register<IDbConnectionFactory>(dbConFactory);
SetConfig(new EndpointHostConfig { DebugMode = true });
var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
mqService.RegisterHandler<Entry>(ServiceController.ExecuteMessage);
mqService.Start();
//install Razor
Plugins.Add(new RazorFormat());
}