本文整理汇总了C#中Funq.Container.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Container.Resolve方法的具体用法?C# Container.Resolve怎么用?C# Container.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Funq.Container
的用法示例。
在下文中一共展示了Container.Resolve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public override void Configure(Container container)
{
//Signal advanced web browsers what HTTP Methods you accept
base.SetConfig(new HostConfig
{
DebugMode = true,
});
container.Register<IAppSettings>(new AppSettings());
var appSettings = container.Resolve<IAppSettings>();
container.Register(c => new ExampleConfig(c.Resolve<IAppSettings>()));
var appConfig = container.Resolve<ExampleConfig>();
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
appConfig.ConnectionString.MapAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
if (appSettings.Get("PerformTestsOnInit", false))
{
log.Debug("Performing database tests...");
DatabaseTest(container.Resolve<IDbConnectionFactory>());
}
}
示例2: Configure
public override void Configure(Container container)
{
//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
},
});
container.Register<IResourceManager>(new ConfigurationResourceManager());
container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>()));
var appConfig = container.Resolve<ExampleConfig>();
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
appConfig.ConnectionString.MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>());
//register different cache implementations depending on availability
const bool hasRedis = false;
if (hasRedis)
container.Register<ICacheClient>(c => new BasicRedisClientManager());
else
container.Register<ICacheClient>(c => new MemoryCacheClient());
log.InfoFormat("AppHost Configured: " + DateTime.Now);
}
示例3: Configure
public override void Configure(Container container)
{
//Signal advanced web browsers what HTTP Methods you accept
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
},
WsdlServiceNamespace = "http://www.servicestack.net/types",
WsdlServiceTypesNamespace = "http://www.servicestack.net/types",
});
container.Register<IResourceManager>(new ConfigurationResourceManager());
var appSettings = container.Resolve<IResourceManager>();
container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>()));
var appConfig = container.Resolve<ExampleConfig>();
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
appConfig.ConnectionString.MapAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
if (appSettings.Get("PerformTestsOnInit", false))
{
log.Debug("Performing database tests...");
DatabaseTest(container.Resolve<IDbConnectionFactory>());
}
}
示例4: Configure
public override void Configure(Container container)
{
JsConfig.EmitCamelCaseNames = true;
var appSettings = new TextFileSettings("~/appSettings.txt".MapHostAbsolutePath(), ":");
container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(
appSettings.Get("database"),
SqlServerDialect.Provider));
container.Register(x => new Log4NetFactory(true));
LogManager.LogFactory = container.Resolve<Log4NetFactory>();
container.Register<ILog>(x => LogManager.GetLogger(GetType()));
AwsAccessKey = appSettings.Get("awsAccessKey");
AwsSecretKey = appSettings.Get("awsSecretKey");
Plugins.Add(new CorsFeature());
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.CreateTableIfNotExists<LinkUrls>();
db.CreateTableIfNotExists<LinkImages>();
}
Routes.Add<FindLinkUrl>("/urls/{Id}", "GET")
.Add<FindLinkUrl>("/urls", "GET")
.Add<AddLinkUrl>("/urls", "POST")
.Add<StartGetImages>("/start", "GET");
}
示例5: Configure
public override void Configure(Container container)
{
//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
},
});
container.Register<IResourceManager>(new ConfigurationResourceManager());
container.Register(c => new ExampleConfig(c.Resolve<IResourceManager>()));
var appConfig = container.Resolve<ExampleConfig>();
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
appConfig.ConnectionString.MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
ConfigureDatabase.Init(container.Resolve<IDbConnectionFactory>());
//The MemoryCacheClient is a great way to get started with caching; nothing external to setup.
container.Register<ICacheClient>(c => new MemoryCacheClient());
//If you give Redis a try, you won't be disappointed. This however requires Redis to be installed.
//container.Register<ICacheClient>(c => new BasicRedisClientManager());
log.InfoFormat("AppHost Configured: {0}", DateTime.Now);
}
示例6: Configure
public override void Configure(Container container)
{
Plugins.Add(new RazorFormat());
container.Register(new DataSource());
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
using (var db = container.Resolve<IDbConnectionFactory>().Open())
{
db.CreateTableIfNotExists<Rockstar>();
db.Insert(Rockstar.SeedData);
}
JsConfig.EmitCamelCaseNames = true;
//Register Typed Config some services might need to access
var appSettings = new AppSettings();
//Register a external dependency-free
container.Register<ICacheClient>(new MemoryCacheClient());
//Configure an alt. distributed persistent cache that survives AppDomain restarts. e.g Redis
//container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379"));
//Enable Authentication an Registration
ConfigureAuth(container);
//Create your own custom User table
using (var db = container.Resolve<IDbConnectionFactory>().Open())
db.DropAndCreateTable<UserTable>();
}
示例7: StatusItemBurritoDayView
public StatusItemBurritoDayView(Container container)
{
this.menu = new NSMenu();
this.menu.AddItem(this.refreshMenuItem);
this.menu.AddItem(this.launchMenuItem);
this.menu.AddItem(NSMenuItem.SeparatorItem);
this.menu.AddItem(this.durationMenuItem);
this.menu.AddItem(this.locationMenuItem);
this.menu.AddItem(this.separatorMenuItem);;
this.menu.AddItem(this.dismissMenuitem);
this.menu.AddItem(this.quitMenuItem);
this.launchMenuItem.Activated += delegate {
var handler = this.urlActivated;
if (handler != null)
{
handler(this, "http://isitburritoday.com");
}
};
this.quitMenuItem.Activated += (sender, e) =>
NSApplication.SharedApplication.Terminate(sender as NSObject);
this.presenters = new IDisposable[]
{
container.Resolve<BurritoDayPresenter, IBurritoDayView>(this),
container.Resolve<UrlActivationPresenter, IUrlActivationView>(this),
};
}
示例8: App
public App()
{
Container = new Container();
Container.Register<ICache>(new DevNullCacheProvider());
Container.Register<IRequestHandler>(new WebClientRequestHandler());
Container.Register<IExportHandler>(new OaiPmhXmlHandler());
Container.Register<IScraper>(new JsonScraper(Container.Resolve<IRequestHandler>()/*, new ScrapeConfig { EnableParallelProcessing = true }*/)
{
Cache = Container.Resolve<ICache>(),
ExportHandler = Container.Resolve<IExportHandler>()
});
}
示例9: ConstructFactoryPopulatesLocalControllerAndExternalControllerByDefault
public void ConstructFactoryPopulatesLocalControllerAndExternalControllerByDefault()
{
var container = new Container();
var factory = new FunqControllerFactory(container, typeof(ExternalController).Assembly);
// test we can still resolve the local one (by default)
var testController = container.Resolve<LocalController>();
Assert.That(testController, Is.Not.Null);
// test we can resolve the external controller (via params assembly)
var externalController = container.Resolve<ExternalController>();
Assert.That(externalController, Is.Not.Null);
}
示例10: Configure
public override void Configure(Container container)
{
container.RegisterAutoWired<EmailProvider>();
container.RegisterAutoWired<FacebookGateway>();
container.RegisterAutoWired<TwitterGateway>();
Plugins.Add(new RazorFormat());
Plugins.Add(new RequestLogsFeature());
var appSettings = new AppSettings();
Plugins.Add(new AuthFeature(() => new CustomSession(),
new IAuthProvider[] {
new CredentialsAuthProvider(appSettings),
new TwitterAuthProvider(appSettings),
new FacebookAuthProvider(appSettings),
}));
container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(),
SqliteDialect.Provider) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
});
//Store User Data into above OrmLite database
container.Register<IAuthRepository>(c =>
new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));
//If using and RDBMS to persist UserAuth, we must create required tables
var authRepo = container.Resolve<IAuthRepository>();
authRepo.InitSchema();
//Register MQ Service
var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
container.Register<IMessageService>(mqService);
container.Register(mqService.MessageFactory);
mqService.RegisterHandler<SMessage>(ServiceController.ExecuteMessage);
mqService.RegisterHandler<CallFacebook>(ServiceController.ExecuteMessage);
mqService.RegisterHandler<EmailMessage>(ServiceController.ExecuteMessage);
mqService.RegisterHandler<PostStatusTwitter>(ServiceController.ExecuteMessage);
mqService.Start();
if (appSettings.Get("ResetAllOnStartUp", false))
{
ResetAll(container, (OrmLiteAuthRepository)authRepo);
}
}
示例11: Configure
public override void Configure(Container container)
{
JsConfig.DateHandler = JsonDateHandler.ISO8601;
container.Register<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(
"~/App_Data/db.sqlite".MapHostAbsolutePath(),
SqliteOrmLiteDialectProvider.Instance));
var resetMovies = container.Resolve<ResetMoviesService>();
resetMovies.Post(null);
Routes
.Add<Movie>("/movies")
.Add<Movie>("/movies/{Id}")
.Add<Movies>("/movies")
.Add<Movies>("/movies/genres/{Genre}");
SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders = {
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
{ "Access-Control-Allow-Headers", "Content-Type, X-Requested-With" },
},
//EnableFeatures = onlyEnableFeatures,
//DebugMode = true, //Show StackTraces for easier debugging
});
}
示例12: Configure
public override void Configure(Container container)
{
LogManager.LogFactory = new ConsoleLogFactory();
SetConfig(new HostConfig
{
DebugMode = true,
EmbeddedResourceSources = { Assembly.GetExecutingAssembly() },
});
Plugins.Add(new RazorFormat
{
LoadFromAssemblies = { typeof(RockstarsService).Assembly }
});
Plugins.Add(new PostmanFeature());
Plugins.Add(new CorsFeature());
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));
using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
{
db.CreateTableIfNotExists<Rockstar>();
db.InsertAll(RockstarsService.SeedData);
}
this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/notfound");
this.CustomErrorHttpHandlers[HttpStatusCode.Unauthorized] = new RazorHandler("/login");
}
示例13: ConstructFactoryPopulatesLocalControllerByDefault
public void ConstructFactoryPopulatesLocalControllerByDefault()
{
var container = new Container();
var factory = new FunqControllerFactory(container);
var testController = container.Resolve<LocalController>();
Assert.That(testController, Is.Not.Null);
}
示例14: should_be_able_to_get_service_impl
public void should_be_able_to_get_service_impl()
{
var c = new Container();
c.EasyRegister<IFoo, Foo>();
Assert.IsInstanceOf<Foo>(c.Resolve<IFoo>());
}
示例15: Application_Start
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
Container = new Container();
Container.Register<ICache>(new DevNullCacheProvider());
Container.Register<IRequestHandler>(new WebClientRequestHandler());
Container.Register<IExportHandler>(new OaiPmhXmlHandler());
Container.Register<IScraper>(new JsonScraper(Container.Resolve<IRequestHandler>())
{
Cache = Container.Resolve<ICache>(),
ExportHandler = Container.Resolve<IExportHandler>()
});
}