本文整理汇总了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;
}
示例2: InitializeLightInject
private static void InitializeLightInject(HttpConfiguration config)
{
var container = new ServiceContainer();
container.RegisterFrom<Composition.CompositionModule>();
container.RegisterApiControllers();
container.EnableWebApi(config);
}
示例3: Register
public static void Register(HttpConfiguration configuration)
{
var container = new ServiceContainer();
container.RegisterApiControllers();
container.Register<ITicketRepository, TicketRepository>(new PerContainerLifetime());
container.EnableWebApi(configuration);
}
示例4: RegisterContainer
private void RegisterContainer()
{
var container = new ServiceContainer();
container.RegisterApiControllers();
container.RegisterFrom<CompositionRoot>();
container.EnableWebApi(this);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}