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


C# IServiceCollection.Where方法代码示例

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


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

示例1: ConfigureServices

        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            _hostingEnv = services.Where(m => m.ServiceType == typeof(IHostingEnvironment) && m.ImplementationInstance != null).Select(m => m.ImplementationInstance).Last() as IHostingEnvironment;
            _startup = new Startup(_hostingEnv);

            ServiceProvider = services.BuildServiceProvider();
            return ServiceProvider;
        }
开发者ID:Pietervdw,项目名称:DBC,代码行数:8,代码来源:Startup.cs

示例2: ServiceManifest

            public ServiceManifest(IServiceCollection fallback)
            {
                var manifestTypes = fallback.Where(t => t.ServiceType.GetTypeInfo().GenericTypeParameters.Length == 0
                        && t.ServiceType != typeof(IRuntimeServices)
                        && t.ServiceType != typeof(IServiceProvider))
                        .Select(t => t.ServiceType).Distinct();

                Services = manifestTypes;
            }
开发者ID:josuecorrea,项目名称:Brochard,代码行数:9,代码来源:HostServiceCollectionExtensions.cs

示例3: MergeServiceDescriptions

        private static void MergeServiceDescriptions(IServiceCollection serviceCollection, IEnumerable<ServiceDescriptor> serviceDescriptors)
        {
            var excludedServiceDescriptors = serviceCollection.Where(service => serviceDescriptors.Contains(service) == false);
            foreach (var descriptor in excludedServiceDescriptors)
            {
                serviceCollection.Remove(descriptor);
            }

            foreach (var descriptor in serviceDescriptors)
            {
                serviceCollection.Add(descriptor);
            }
        }
开发者ID:app-enhance,项目名称:ae-di,代码行数:13,代码来源:IServiceCollectionExtensions.cs

示例4: ConfigureServices

        // This method gets called by the runtime.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            //var logger = loggerFactory.CreateLogger(typeof(Program).FullName);

            //logger.LogInformation("Handled in {ExecutionTime} ms", executionTime);

            Bifrost.Configuration.Configure.DiscoverAndConfigure(
                assembliesConfigurationBuilderCallback: builder => builder.IncludeAll().ExceptAssembliesStartingWith("Microsoft"),
                additionalAssemblyProviders: new[] { new LibraryAssemblyProvider() }
            );

            services.AddSignalR();

            ContainerCreator.Kernel.Populate(services.Where(s => !s.HasBinding()));
            return ContainerCreator.Kernel.Get<IServiceProvider>();
        }
开发者ID:msdevno,项目名称:GeekBeer,代码行数:17,代码来源:Startup.cs

示例5: ConfigureServices

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddCustomPageCore();

            services.AddTransient<IWidgetProvider, JsonWidgetProvider>();


            var builder = new ContainerBuilder();
            builder.Populate(services);


            foreach (var descriptor in services.Where(i => i.ImplementationInstance is IModule))
            {
                builder.RegisterModule(descriptor.ImplementationInstance as IModule);
            }

            var container = builder.Build();

            _serviceProvider = container.Resolve<IServiceProvider>();
        }
开发者ID:andyshao,项目名称:CustomPages,代码行数:23,代码来源:Startup.cs

示例6: AssertContainsSingle

        private void AssertContainsSingle(
            IServiceCollection services,
            Type serviceType,
            Type implementationType)
        {
            var matches = services
                .Where(sd =>
                    sd.ServiceType == serviceType &&
                    sd.ImplementationType == implementationType)
                .ToArray();

            if (matches.Length == 0)
            {
                Assert.True(
                    false,
                    $"Could not find an instance of {implementationType} registered as {serviceType}");
            }
            else if (matches.Length > 1)
            {
                Assert.True(
                    false,
                    $"Found multiple instances of {implementationType} registered as {serviceType}");
            }
        }
开发者ID:phinq19,项目名称:git_example,代码行数:24,代码来源:MvcCoreServiceCollectionExtensionsTest.cs

示例7: AssertServiceCountEquals

        private void AssertServiceCountEquals(
            IServiceCollection services,
            Type serviceType,
            int expectedServiceRegistrationCount)
        {
            var serviceDescriptors = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == serviceType);
            var actual = serviceDescriptors.Count();

            Assert.True(
                (expectedServiceRegistrationCount == actual),
                $"Expected service type '{serviceType}' to be registered {expectedServiceRegistrationCount}" +
                $" time(s) but was actually registered {actual} time(s).");
        }
开发者ID:phinq19,项目名称:git_example,代码行数:13,代码来源:MvcCoreServiceCollectionExtensionsTest.cs

示例8: PrepareRouteServices

        private static void PrepareRouteServices(IServiceCollection serviceCollection)
        {
            var modelBindingActionInvokerFactoryType = typeof(IModelBindingActionInvokerFactory);

            if (serviceCollection.All(s => s.ServiceType != modelBindingActionInvokerFactoryType))
            {
                serviceCollection.TryAddEnumerable(
                    ServiceDescriptor.Transient<IActionInvokerProvider, ModelBindingActionInvokerProvider>());
                serviceCollection.TryAddSingleton(modelBindingActionInvokerFactoryType, typeof(ModelBindingActionInvokerFactory));
            }

            routeServiceProvider = serviceCollection.BuildServiceProvider();

            serviceCollection.RemoveSingleton(modelBindingActionInvokerFactoryType);

            var actionInvokerProviders = serviceCollection.Where(s => s.ServiceType == typeof(IActionInvokerProvider)).ToList();
            if (actionInvokerProviders.Count > 1)
            {
                serviceCollection.Remove(actionInvokerProviders.LastOrDefault());
            }
        }
开发者ID:Cream2015,项目名称:MyTested.AspNetCore.Mvc,代码行数:21,代码来源:TestApplication.cs


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