本文整理汇总了C#中Funq.Container.RegisterAutoWiredAs方法的典型用法代码示例。如果您正苦于以下问题:C# Container.RegisterAutoWiredAs方法的具体用法?C# Container.RegisterAutoWiredAs怎么用?C# Container.RegisterAutoWiredAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq.Container
的用法示例。
在下文中一共展示了Container.RegisterAutoWiredAs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public FunqRegistry Register(Container container)
{
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<IDbConnection>(c =>
new ProfiledDbConnection(
new SqlCeConnection(ConfigurationManager.ConnectionStrings["Iso3166_1"].ConnectionString),
Profiler.Current))
.ReusedWithin(ReuseScope.None);
container.RegisterAutoWiredAs<CountryRepository, ICountryRepository>()
.ReusedWithin(ReuseScope.None);
container.RegisterAutoWiredAs<LanguageRepository, ILanguageRepository>()
.ReusedWithin(ReuseScope.None);
var logFactory = new ElmahVerboserLoggerFactory(new ElmahLogFactory(new NullLogFactory()));
// allows ServiceStack to log its own error (for instance 404)
LogManager.LogFactory = logFactory;
// allow services to declare the ILogFactory dependency instead of depending on the global LogManager
container.Register<ILogFactory>(logFactory);
container.RegisterAutoWiredAs<TranslationRepository, ITranslationRepository>()
.ReusedWithin(ReuseScope.None);
return this;
}
示例2: Register
public static void Register(Container container)
{
container.RegisterAutoWiredAs<PlaceService, IPlaceService>().ReusedWithin(ReuseScope.Container);
container.RegisterAutoWiredAs<HotelService, IHotelService>().ReusedWithin(ReuseScope.Container);
container.RegisterAutoWiredAs<HotelPriceService, IHotelPriceService>().ReusedWithin(ReuseScope.Container);
container.RegisterAutoWiredAs<FlightService, IFlightService>().ReusedWithin(ReuseScope.Container);
}
示例3: Configure
public override void Configure(Container container)
{
// Registering the dependencies that will be used during the application lifetime and by the service itself.
container.RegisterAutoWiredAs<Configuration, IConfiguration>().ReusedWithin(ReuseScope.Container);
container.RegisterAutoWiredAs<MayLilyMetadataSource, IMetadataSource>().ReusedWithin(ReuseScope.Container);
container.RegisterAutoWiredAs<MayLilyContext, IDbMigrator>().ReusedWithin(ReuseScope.None);
container.RegisterAutoWiredAs<MayLilyContext, IMayLilyContext>().ReusedWithin(ReuseScope.None);
}
示例4: Register
public static void Register(Container container)
{
// add service validation
container.RegisterValidators(ReuseScope.Container, typeof(ServiceStackServiceSolutionValidationAseembly).Assembly);
container.RegisterAutoWiredAs<WidgetManager, IWidgetManager>();
container.RegisterAutoWiredAs<InMemoryWidgetRepository, IWidgetRepository>();
RegisterExternalAssemblies(container);
}
示例5: ConfigureAuth
private void ConfigureAuth(Container container) {
container.Register(GetUserSession).ReusedWithin(ReuseScope.Request);
container.Register(GetUserProfile).ReusedWithin(ReuseScope.Request);
container.RegisterAutoWiredAs<OrmLiteAuthRepository, IAuthRepository>().ReusedWithin(ReuseScope.Request);
container.RegisterAutoWiredAs<OrmLiteAuthRepository, IUserAuthRepository>().ReusedWithin(ReuseScope.Request);
var auth_providers = new IAuthProvider[] { new CredentialsAuthProvider() };
var auth_feature = new AuthFeature(() => new BoilerUserSession(), auth_providers) {
HtmlRedirect = "/index.html"
};
Plugins.Add(auth_feature);
}
示例6: Configure
public override void Configure(Container container)
{
Store = new DocumentStore { ConnectionStringName = "RavenDB" };
Store.Initialize();
IndexCreation.CreateIndexes(typeof(Vacancies_WithApplicantCount).Assembly, Store);
container.Register<IDocumentStore>(c => Store);
container.Register(c => c.Resolve<IDocumentStore>()
.OpenSession())
.ReusedWithin(ReuseScope.Request);
container.RegisterAutoWiredAs<VacancyService, IVacancyService>();
container.RegisterAutoWiredAs<TestService,ITestService>();
ControllerBuilder.Current.SetControllerFactory(
new FunqControllerFactory(container));
LogManager.LogFactory = new ConsoleLogFactory();
}
示例7: Configure
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
/// <param name="container"></param>
public override void Configure(Container container)
{
//Config examples
//this.Plugins.Add(new PostmanFeature());
//Plugins.Add(new CorsFeature());
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new RazorFormat());
Plugins.Add(new ServerEventsFeature());
MimeTypes.ExtensionMimeTypes["jsv"] = "text/jsv";
SetConfig(new HostConfig
{
DebugMode = AppSettings.Get("DebugMode", false),
DefaultContentType = MimeTypes.Json,
AllowFileExtensions = { "jsx" },
});
CustomErrorHttpHandlers.Remove(HttpStatusCode.Forbidden);
//Register all Authentication methods you want to enable for this web app.
Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] {
new TwitterAuthProvider(AppSettings), //Sign-in with Twitter
new FacebookAuthProvider(AppSettings), //Sign-in with Facebook
new GithubAuthProvider(AppSettings), //Sign-in with GitHub OAuth Provider
}));
container.RegisterAutoWiredAs<MemoryChatHistory, IChatHistory>();
var redisHost = AppSettings.GetString("RedisHost");
if (redisHost != null)
{
container.Register<IRedisClientsManager>(new RedisManagerPool(redisHost));
container.Register<IServerEvents>(c =>
new RedisServerEvents(c.Resolve<IRedisClientsManager>()));
container.Resolve<IServerEvents>().Start();
}
Plugins.Add(new RazorFormat
{
LoadFromAssemblies = { typeof(CefResources).Assembly },
});
SetConfig(new HostConfig
{
DebugMode = true,
EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(CefResources) },
});
}
示例8: registerDependencies
void registerDependencies(Container container)
{
// ReuseScope.None disposes the Db connection.
// Needed for Sql Server
container.RegisterAutoWiredAs<Repository, IRepository>().ReusedWithin(ReuseScope.None);
container.RegisterAutoWired<BaseService>().ReusedWithin(ReuseScope.None);
container.RegisterAutoWired<HomeService>().ReusedWithin(ReuseScope.None);
container.RegisterAutoWired<SearchService>().ReusedWithin(ReuseScope.None);
container.RegisterAutoWiredAs<ProductsService, IProductsService>().ReusedWithin(ReuseScope.None);
// not exposing this on PublicMvc
//container.RegisterAutoWired<ProductsProcessorService>().ReusedWithin(ReuseScope.None);
var connectionString = ConfigurationManager
.ConnectionStrings["DiffStack"].ConnectionString;
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
connectionString,
SqlServerDialect.Provider
)
);
}
示例9: Does_AutoWire_MultiFunq_types
public void Does_AutoWire_MultiFunq_types()
{
var container = new Container();
container.RegisterAutoWiredAs<Foo, IFoo>();
container.RegisterAutoWiredAs<Bar, IBar>();
container.RegisterAutoWired<Test>();
var foo = container.Resolve<IFoo>();
Assert.That(foo, Is.Not.Null);
var bar = container.Resolve<IBar>();
Assert.That(bar, Is.Not.Null);
container.RegisterAutoWired<MultiFunqTest>();
var test = container.Resolve<MultiFunqTest>();
Assert.That(test.CtorFooBar, Is.Not.Null);
Assert.That(test.CtorFooBar(new Foo()), Is.Not.Null);
Assert.That(test.FunqFooBar, Is.Not.Null);
Assert.That(test.FunqFooBar(new Foo()), Is.Not.Null);
Assert.That(test.FunqTestFooBar, Is.Not.Null);
Assert.That(test.FunqTestFooBar(new Test(), new Foo()), Is.Not.Null);
}
示例10: Does_AutoWire_Funq_types
public void Does_AutoWire_Funq_types()
{
var container = new Container();
container.RegisterAutoWiredAs<Foo, IFoo>();
container.RegisterAutoWired<FunqTest>();
var test = container.Resolve<FunqTest>();
Assert.That(test.CtorFoo, Is.Not.Null);
Assert.That(test.CtorFoo(), Is.Not.Null);
Assert.That(test.FunqFoo, Is.Not.Null);
Assert.That(test.FunqFoo(), Is.Not.Null);
}
示例11: Configure
public override void Configure (Container container)
{
LogManager.LogFactory = new NLogFactory ();
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"REQ {0}: {1} {2} {3} {4} {5}\n",
DateTimeOffset.Now.Ticks, req.HttpMethod,
req.OperationName, req.RemoteIp, req.RawUrl, req.UserAgent));
});
this.RequestFilters.Add ((req, resp, requestDto) => {
ILog log = LogManager.GetLogger (GetType ());
log.Info (string.Format (
"RES {0}: {1} {2}\n",
DateTimeOffset.Now.Ticks, resp.StatusCode, resp.ContentType));
});
JsConfig.DateHandler = JsonDateHandler.ISO8601;
Plugins.Add (new AuthFeature (() => new AuthUserSession (),
new IAuthProvider[] { new BasicAuthProvider () })
);
Plugins.Add (new RegistrationFeature ());
Plugins.Add (new RequestLogsFeature ());
container.RegisterAutoWiredAs<Scheduler, IScheduler> ();
container.Register<ICacheClient> (new MemoryCacheClient ());
container.Register<IDbConnectionFactory> (new OrmLiteConnectionFactory
(@"Data Source=db.sqlite;Version=3;", SqliteOrmLiteDialectProvider.Instance));
//Use OrmLite DB Connection to persist the UserAuth and AuthProvider info
container.Register<IUserAuthRepository> (c => new OrmLiteAuthRepository (c.Resolve<IDbConnectionFactory> ()));
Plugins.Add (new ValidationFeature ());
container.RegisterValidators (typeof(AppHost).Assembly);
var config = new EndpointHostConfig ();
if (m_debugEnabled) {
config.DebugMode = true; //Show StackTraces in service responses during development
config.WriteErrorsToResponse = true;
config.ReturnsInnerException = true;
}
container.AutoWire (this);
SetConfig (config);
CreateMissingTables (container);
}
示例12: Configure
public override void Configure(Container container)
{
SetConfig(new EndpointHostConfig()
{
EnableFeatures = Feature.All.Remove(Feature.Metadata),
DefaultRedirectPath = "/default",
GlobalResponseHeaders = { { "X-Powered-by", "Test" }, { "Server", "Test" } },
AllowJsonpRequests = true,
});
StreamExtensions.GZipProvider = new NetGZipProvider();
StreamExtensions.DeflateProvider = new NetDeflateProvider();
container.Register<ICacheClient>(x => new PooledRedisClientManager("10.10.3.166:6379").GetCacheClient());
container.Register<Logger>(x => LogManager.GetLogger("MemoryLeakTestLog"));
container.RegisterAutoWiredAs<BusinessRule, IBusinessRule>().ReusedWithin(ReuseScope.None);
}
示例13: ConfigureAppHost
public void ConfigureAppHost(Container container, bool useTestDatabase = false)
{
JsConfig.EmitCamelCaseNames = true;
JsConfig.DateHandler = JsonDateHandler.ISO8601;
_appHost.Plugins.Add(new ValidationFeature());
container.RegisterValidators(typeof (AppHost).Assembly);
container.Register<ICacheClient>(new MemoryCacheClient());
_appHost.Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[]
{
new CredentialsAuthProvider()
}));
if (useTestDatabase)
{
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(
":memory:",
false,
SqliteDialect.Provider));
}
else
{
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(
ConfigurationManager.ConnectionStrings["SqlLiteConnection"].ConnectionString.MapHostAbsolutePath(),
SqliteDialect.Provider));
}
container.RegisterAutoWiredAs<BicyleRepository, IBicyleRepository>().ReusedWithin(ReuseScope.Request);
container.Register<IUserAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));
var userAuthRepository = (OrmLiteAuthRepository) container.Resolve<IUserAuthRepository>();
userAuthRepository.CreateMissingTables();
if (userAuthRepository.GetUserAuthByUserName("[email protected]") == null)
{
userAuthRepository.CreateUserAuth(
new UserAuth {Email = "[email protected]", DisplayName = "Admin User"}, "admin");
}
InitializeDatabase(container);
}
示例14: RegisterDependencies
private static void RegisterDependencies(Container container)
{
//Register all your dependencies
container.Register<ICacheClient>(new MemoryCacheClient());
container.Register<IAuth>(new PasswordAuth());
container.Register<IRepository>(AzureStorage.CreateSingleton(
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString
));
container.RegisterAutoWired<XpmsAuthProvider>().ReusedWithin(ReuseScope.Hierarchy);
container.RegisterAutoWiredAs<Mailer, IMailer>().ReusedWithin(ReuseScope.Hierarchy);
container.RegisterProcesses<AbstractProcess>();
container.RegisterValidators(typeof(SignupRequestValidator).Assembly);
container.RegisterDataRecords<IRepoData>(typeof(AzureStorage).Assembly);
}
示例15: Configure
/// <summary>
/// Application specific configuration
/// This method should initialize any IoC resources utilized by your web service classes.
/// </summary>
/// <param name="container"></param>
public override void Configure(Container container)
{
JsConfig.EmitCamelCaseNames = true;
Plugins.Add(new ServerEventsFeature());
InitializeAppSettings ();
Plugins.Add (new RazorFormat {
LoadFromAssemblies = { typeof(CefResources).Assembly },
});
SetConfig (new HostConfig {
DebugMode = AppSettings.Get("DebugMode", false),
DefaultContentType = MimeTypes.Json,
AllowFileExtensions = { "jsx" },
EmbeddedResourceBaseTypes = { typeof(AppHost), typeof(CefResources) },
});
Routes.Add<NativeHostAction>("/nativehost/{Action}");
ServiceController.RegisterService(typeof(NativeHostService));
CustomErrorHttpHandlers.Remove(HttpStatusCode.Forbidden);
//Register all Authentication methods you want to enable for this web app.
Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] {
new TwitterAuthProvider(AppSettings) //Sign-in with Twitter
}));
container.RegisterAutoWiredAs<MemoryChatHistory, IChatHistory>();
var redisHost = AppSettings.GetString("RedisHost");
if (redisHost != null)
{
container.Register<IRedisClientsManager>(new RedisManagerPool(redisHost));
container.Register<IServerEvents>(c =>
new RedisServerEvents(c.Resolve<IRedisClientsManager>()));
container.Resolve<IServerEvents>().Start();
}
}