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


C# Container.Resolve方法代码示例

本文整理汇总了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>());
			}
		}
开发者ID:Qasemt,项目名称:ServiceStack.Examples,代码行数:26,代码来源:AppHost.cs

示例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);
		}
开发者ID:nuxleus,项目名称:ServiceStack.Examples,代码行数:35,代码来源:AppHost.cs

示例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>());
			}
		}
开发者ID:justinrolston,项目名称:ServiceStack.Examples,代码行数:32,代码来源:AppHost.cs

示例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");
        }
开发者ID:KyleGobel,项目名称:Screenshot,代码行数:29,代码来源:AppHost.cs

示例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);
        }
开发者ID:rasikas,项目名称:ServiceStack.Examples,代码行数:32,代码来源:AppHost.cs

示例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>();
        }
开发者ID:nustack,项目名称:ServiceStack,代码行数:34,代码来源:AppHost.cs

示例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),
            };
        }
开发者ID:ataranto,项目名称:tepeyac,代码行数:33,代码来源:StatusItemBurritoDayView.cs

示例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>()
            });
        }
开发者ID:unibirmingham,项目名称:TalisScrape,代码行数:13,代码来源:App.xaml.cs

示例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);
        }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:13,代码来源:FunqControllerFactoryTests.cs

示例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);
            }
        }
开发者ID:NickPapageorgio,项目名称:ServiceStack.UseCases,代码行数:51,代码来源:Global.asax.cs

示例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
			});

		}
开发者ID:asunar,项目名称:ServiceStack.Examples,代码行数:30,代码来源:Global.asax.cs

示例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");
        }
开发者ID:ServiceStackApps,项目名称:RazorRockstars,代码行数:29,代码来源:AppHost.cs

示例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);
 }
开发者ID:Qasemt,项目名称:NServiceKit,代码行数:7,代码来源:FunqControllerFactoryTests.cs

示例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>());
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:7,代码来源:funq_easy_registration.cs

示例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>()
            });
        }
开发者ID:unibirmingham,项目名称:TalisScrape,代码行数:16,代码来源:Global.asax.cs


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