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


C# ServiceContainer.EnableWebApi方法代码示例

本文整理汇总了C#中ServiceContainer.EnableWebApi方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer.EnableWebApi方法的具体用法?C# ServiceContainer.EnableWebApi怎么用?C# ServiceContainer.EnableWebApi使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceContainer的用法示例。


在下文中一共展示了ServiceContainer.EnableWebApi方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnableLightInject

 public static IServiceContainer EnableLightInject(this HttpConfiguration configuration)
 {
     var container = new ServiceContainer();
     container.RegisterApiControllers();
     container.EnableWebApi(configuration);
     return container;
 }
开发者ID:seesharper,项目名称:LightInject.WebApiSkeleton,代码行数:7,代码来源:ConfigurationExtensions.cs

示例2: InitializeLightInject

 private static void InitializeLightInject(HttpConfiguration config)
 {
     var container = new ServiceContainer();
     container.RegisterFrom<Composition.CompositionModule>();
     container.RegisterApiControllers();
     container.EnableWebApi(config);
 }
开发者ID:dzimchuk,项目名称:SASRotation,代码行数:7,代码来源:Startup.cs

示例3: Register

 public static void Register(HttpConfiguration configuration)
 {
     var container = new ServiceContainer();
     container.RegisterApiControllers();           
     container.Register<ITicketRepository, TicketRepository>(new PerContainerLifetime());
     container.EnableWebApi(configuration);
 }
开发者ID:santosh-mnrec,项目名称:demo-realtime-tickets,代码行数:7,代码来源:DependencyConfig.cs

示例4: RegisterContainer

 private void RegisterContainer()
 {
     var container = new ServiceContainer();
     container.RegisterApiControllers();
     container.RegisterFrom<CompositionRoot>();
     container.EnableWebApi(this);
 }
开发者ID:Takaloy,项目名称:Hello-Owin-World,代码行数:7,代码来源:WebApiConfig.cs

示例5: Register

		public static void Register(ServiceContainer container, HttpConfiguration config)
		{
			container.RegisterControllers();
			container.RegisterApiControllers();

			#region Services
			container.Register<IPluralizeProxy, PluralizeProxy>();
			container.Register(factory => PluralizationService.CreateService(CultureInfo.GetCultureInfo("en")));
			container.Register<ISitemapGenerator, SitemapGenerator>();
			#endregion

			#region Tracing
			container.Register<IDiagnosticTrace, DiagnosticTrace>();
			#endregion

			#region Repositories
			container.Register<IDbContext, NhDbContext>();
			container.Register<IDataRepository<Repository>, DataRepository<Repository>>(new PerScopeLifetime());
			container.Register<IDataRepository<Session>, DataRepository<Session>>(new PerScopeLifetime());
			container.Register<IDataRepository<LogEntry>, DataRepository<LogEntry>>(new PerScopeLifetime());
			#endregion

			container.EnableMvc();
			container.EnablePerWebRequestScope();
			container.EnableWebApi(config);
		}
开发者ID:nHook,项目名称:nH.Web,代码行数:26,代码来源:DIConfig.cs

示例6: Application_Start

 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     var container = new ServiceContainer();
     container.RegisterApiControllers();
     container.Register<IDataStore, FakeDataStore>();
     container.EnablePerWebRequestScope();
     container.EnableWebApi(GlobalConfiguration.Configuration);
 }
开发者ID:chenzuo,项目名称:Restival,代码行数:9,代码来源:Global.asax.cs

示例7: Register

        /// <summary>
        /// Registers main components
        /// </summary>
        /// <param name="config">Http Configuration</param>
        public static void Register(HttpConfiguration config)
        {
            var container = new ServiceContainer();
            container.RegisterApiControllers();

            container.EnablePerWebRequestScope();
            container.EnableWebApi(GlobalConfiguration.Configuration);
            container.EnableMvc();

            // Register Services
            RegisterServices(container);
        }
开发者ID:ryanwoodcox,项目名称:HelloWorld,代码行数:16,代码来源:LightInjectConfig.cs

示例8: Configuration

        public void Configuration(IAppBuilder app)
        {
            var configuration = new HttpConfiguration();
            ConfigureHttpRoutes(configuration);
            ConfigureMediaFormatter(configuration);

            var container = new ServiceContainer();
            container.RegisterFrom<WebApiCompositionRoot>();            
            container.EnableWebApi(configuration);           

            app.Use<RequestContextMiddleware>();
            app.Use<RequestLoggingMiddleware>(container.GetInstance<Type, ILog>(typeof (RequestLogDecorator)));                              
            app.UseWebApi(configuration);
        }
开发者ID:seesharper,项目名称:Blog.WebApiRequestLogging,代码行数:14,代码来源:Startup.cs

示例9: Register

		public static void Register(ServiceContainer container, HttpConfiguration config)
		{
			container.RegisterApiControllers();

			#region Tracing
			container.Register<IDiagnosticTrace, DiagnosticTrace>();
			container.Register<ITracer, NhTracer>();
			#endregion

			#region Loggers
			container.Register<ILogger, LoggerProxy>();
			container.Register<IConsole, ConsoleProxy>();
			#endregion

			#region Repositories
			container.Register<IDbContext, NhDbContext>(new PerContainerLifetime());
			container.Register<IDataRepository<Repository>, DataRepository<Repository>>(new PerScopeLifetime());
			container.Register<IDataRepository<Session>, DataRepository<Session>>(new PerScopeLifetime());
			container.Register<IDataRepository<LogEntry>, DataRepository<LogEntry>>(new PerScopeLifetime());
			#endregion

			#region Services
			container.Register<IActionContextService, ActionContextService>();
			container.Register<ISourceService, SourceService>();
			container.Register<IPathService, PathService>();
			container.Register<IPublishService, PublishService>();
			container.Register<IIOService, IOService>();
			container.Register<IPluralizeProxy, PluralizeProxy>();
			container.Register(factory => PluralizationService.CreateService(CultureInfo.GetCultureInfo("en")));
			#endregion

			#region Processors
			container.Register<INhContext, NhContext>(new PerScopeLifetime());
			container.Register<IProcessor<GitHubMessage>, GitHubProcessor>();
			container.Register<IProcessor<BitBucketMessage>, BitBucketProcessor>();
			#endregion

			#region Settings
			container.Register(factory => ConfigurationManager.AppSettings);
			#endregion

			container.EnablePerWebRequestScope();
			container.EnableWebApi(config);
		}
开发者ID:nHook,项目名称:nH.Api,代码行数:44,代码来源:DiConfig.cs

示例10: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var container = new ServiceContainer();
            container.RegisterApiControllers();

            container.Register<DbContext, TasksEntities>();
            container.Register<ITasksRepository, TasksRepository>(new PerScopeLifetime());
            container.Register<ITaskStatusesRepository, TaskStatusesRepository>(new PerScopeLifetime());
            container.Register<ITaskTypesRepository, TaskTypesRepository>(new PerScopeLifetime());

            container.EnablePerWebRequestScope();
            container.EnableWebApi(GlobalConfiguration.Configuration);
        }
开发者ID:snakeduse,项目名称:TestTasks,代码行数:19,代码来源:Global.asax.cs

示例11: Configuration

        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            var container = new ServiceContainer();

            Configure(container);
            container.ScopeManagerProvider = new PerLogicalCallContextScopeManagerProvider();
            container.RegisterApiControllers(typeof(Startup).Assembly);
            container.EnableWebApi(config);

            ConfigureHttpRoutes(config);
            config.MapHttpAttributeRoutes();
            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());

            ConfigureSwagger(config);

            app.UseWebApi(config);
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
        }
开发者ID:Yazurka,项目名称:IconKeeper,代码行数:20,代码来源:Startup.cs

示例12: UseDependencyInjection

        /// <summary>
        /// Register dependencies with LightInject container and set resolver
        /// </summary>
        protected virtual void UseDependencyInjection(HttpConfiguration config)
        {
            var container = new ServiceContainer();
            SqliteConnection connection = new SqliteConnection("Data Source=" + _databasePath);
            connection.Open();

            container.RegisterApiControllers();
            container.EnableWebApi(config);
            container.Register<IDbConnection>(factory => connection);
            container.Register<IDatabaseInitializer, SQLiteDatabaseInitializer>(new PerRequestLifeTime());
            container.Register<IRepository<Tag>, TagsRepository>(new PerRequestLifeTime());
            container.Register<IRepository<UnitOfMeasure>, UnitsOfMeasureRepository>(new PerRequestLifeTime());
            container.Register<IRepository<RecipeTagXref>, RecipeXrefRepository>(new PerRequestLifeTime());
            container.Register<IRepository<RecipeIngredient>, RecipeIngredientsRepository>(new PerRequestLifeTime());
            container.Register<IRepository<RecipeStep>, RecipeStepsRepository>(new PerRequestLifeTime());
            container.Register<IRepository<Recipe>, RecipesRepository>(new PerRequestLifeTime());
            _dbInitializer = container.GetInstance<IDatabaseInitializer>();
            config.DependencyResolver = new LightInjectResolver(container);
        }
开发者ID:napalm684,项目名称:ReciPiBook,代码行数:22,代码来源:Startup.cs


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