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


C# IServiceCollection.AddService方法代码示例

本文整理汇总了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;
 }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:10,代码来源:StoreApi.cs

示例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;
            }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:32,代码来源:ServiceConfiguration.Tests.cs

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

示例4: ApplyTo

 public static void ApplyTo(IServiceCollection services, Type targetType)
 {
     services.AddService<IModelBuilder>((sp, next) => new RestierOperationModelBuilder(targetType)
     {
         InnerHandler = next,
     });
 }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:7,代码来源:RestierOperationModelBuilder.cs

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

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

示例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;
            }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:20,代码来源:DefaultModelHandler.Tests.cs

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

示例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;
            }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:12,代码来源:InvocationContext.Tests.cs

示例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;
 }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:8,代码来源:FallbackTests.cs

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

示例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;
            }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:17,代码来源:Api.Tests.cs

示例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;
            }
开发者ID:chinadragon0515,项目名称:RESTier,代码行数:19,代码来源:ApiConfiguration.Tests.cs


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