本文整理汇总了C#中IServiceCollection.AddService方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddService方法的具体用法?C# IServiceCollection.AddService怎么用?C# IServiceCollection.AddService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceCollection
的用法示例。
在下文中一共展示了IServiceCollection.AddService方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
services = ApiBase.ConfigureApi(apiType, services);
services.AddService<IModelBuilder>((sp, next) => new TestModelProducer(StoreModel.Model));
services.AddService<IModelMapper>((sp, next) => new TestModelMapper());
services.AddService<IQueryExpressionSourcer>((sp, next) => new TestQueryExpressionSourcer());
services.AddService<IChangeSetInitializer>((sp, next) => new TestChangeSetInitializer());
services.AddService<ISubmitExecutor>((sp, next) => new TestSubmitExecutor());
return services;
}
示例2: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
var i = 0;
services.AddService<ISomeService>((sp, next) => new SomeService
{
Inner = next,
Value = i++
})
.AddService<ISomeService>((sp, next) => new SomeService
{
Inner = next,
Value = i++
})
.AddService<ISomeService>((sp, next) => new SomeService
{
Inner = next,
Value = i++
})
.AddService<ISomeService>((sp, next) => new SomeService
{
Inner = next,
Value = i++
})
.AddService<ISomeService, SomeService>();
services.AddScoped(apiType, apiType)
.AddScoped(typeof(ApiBase), apiType)
.AddScoped<ApiContext>();
services.TryAddSingleton<ApiConfiguration>();
return services;
}
示例3: ApplyTo
public static void ApplyTo(
IServiceCollection services,
Type targetType)
{
Ensure.NotNull(services, "services");
Ensure.NotNull(targetType, "targetType");
// The model builder must maintain a singleton life time, for holding states and being injected into
// some other services.
services.AddSingleton(new RestierModelExtender(targetType));
services.AddService<IModelBuilder, ModelBuilder>();
services.AddService<IModelMapper, ModelMapper>();
services.AddService<IQueryExpressionExpander, QueryExpressionExpander>();
services.AddService<IQueryExpressionSourcer, QueryExpressionSourcer>();
}
示例4: ApplyTo
public static void ApplyTo(IServiceCollection services, Type targetType)
{
services.AddService<IModelBuilder>((sp, next) => new RestierOperationModelBuilder(targetType)
{
InnerHandler = next,
});
}
示例5: ApplyTo
public static void ApplyTo(
IServiceCollection services,
Type targetType)
{
Ensure.NotNull(services, "services");
Ensure.NotNull(targetType, "targetType");
services.AddService<IOperationAuthorizer>((sp, next) => new ConventionBasedOperationAuthorizer(targetType));
}
示例6: ApplyTo
/// <inheritdoc/>
public static void ApplyTo(
IServiceCollection services,
Type targetType)
{
Ensure.NotNull(services, "services");
Ensure.NotNull(targetType, "targetType");
services.AddService<IChangeSetItemFilter>(
(sp, next) => new ConventionBasedChangeSetItemFilter(targetType));
}
示例7: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
services.AddService<IModelBuilder>((sp, next) => new TestModelProducer());
services.AddService<IModelBuilder>((sp, next) => new TestModelExtender(2)
{
InnerHandler = next,
});
services.AddService<IModelBuilder>((sp, next) => new TestModelExtender(3)
{
InnerHandler = next,
});
services.AddScoped(apiType, apiType)
.AddScoped(typeof(ApiBase), apiType)
.AddScoped<ApiContext>();
services.TryAddSingleton<ApiConfiguration>();
return services;
}
示例8: ApplyTo
/// <inheritdoc/>
public static void ApplyTo(
IServiceCollection services,
Type targetType)
{
Ensure.NotNull(services, "services");
Ensure.NotNull(targetType, "targetType");
services.AddService<IQueryExpressionProcessor>(
(sp, next) => new ConventionBasedQueryExpressionProcessor(targetType)
{
Inner = next,
});
}
示例9: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
services.AddScoped(apiType, apiType)
.AddScoped(typeof(ApiBase), apiType)
.AddScoped<ApiContext>();
services.TryAddSingleton<ApiConfiguration>();
services.AddService<IServiceA>((sp, next) => ApiService);
return services;
}
示例10: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
services.AddService<IModelBuilder>((sp, next) => new TestModelProducer(FallbackModel.Model));
services.AddService<IModelMapper>((sp, next) => new FallbackModelMapper());
services.AddService<IQueryExpressionSourcer>((sp, next) => new FallbackQueryExpressionSourcer());
services = ApiBase.ConfigureApi(apiType, services);
return services;
}
示例11: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
Func<IServiceProvider, IDataStoreManager<string, TripPinDataSource>> defaultDataStoreManager =
sp => new DefaultDataStoreManager<string, TripPinDataSource>()
{
MaxDataStoreInstanceCapacity = 1000,
MaxDataStoreInstanceLifeTime = new TimeSpan(0, 30, 0)
};
services.AddService<IModelBuilder>((sp, next) => new ModelBuilder());
services.AddService<IChangeSetInitializer>((sp, next) => new ChangeSetInitializer<TripPinDataSource>());
services.AddService<ISubmitExecutor>((sp, next) => new SubmitExecutor());
services.AddSingleton(defaultDataStoreManager);
return ApiBase.ConfigureApi(apiType, services);
}
示例12: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
var modelBuilder = new TestModelBuilder();
var modelMapper = new TestModelMapper();
var querySourcer = new TestQuerySourcer();
var changeSetPreparer = new TestChangeSetInitializer();
var submitExecutor = new TestSubmitExecutor();
services.AddCoreServices(apiType);
services.AddService<IModelBuilder>((sp, next) => modelBuilder);
services.AddService<IModelMapper>((sp, next) => modelMapper);
services.AddService<IQueryExpressionSourcer>((sp, next) => querySourcer);
services.AddService<IChangeSetInitializer>((sp, next) => changeSetPreparer);
services.AddService<ISubmitExecutor>((sp, next) => submitExecutor);
return services;
}
示例13: ConfigureApi
public static new IServiceCollection ConfigureApi(Type apiType, IServiceCollection services)
{
var q1 = new ServiceB("q1Pre", "q1Post");
var q2 = new ServiceB("q2Pre", "q2Post");
services.AddService<IServiceB>((sp, next) => q1)
.AddService<IServiceB>((sp, next) =>
{
q2.InnerHandler = next;
return q2;
});
services.AddScoped(apiType, apiType)
.AddScoped(typeof(ApiBase), apiType)
.AddScoped<ApiContext>();
services.TryAddSingleton<ApiConfiguration>();
return services;
}