Ejemplo n.º 1
0
        /// <summary>
        /// 使用Prism注册并初始化容器,需要确保Shiny和Prism使用相同的容器
        /// </summary>
        /// <param name="services"></param>
        /// <returns></returns>
        public override IServiceProvider CreateServiceProvider(IServiceCollection services)
        {
            ContainerLocator.SetContainerExtension(() => new DryIocContainerExtension());
            var container = ContainerLocator.Container.GetContainer();

            DryIocAdapter.Populate(container, services);
            return(container.GetServiceProvider());
        }
Ejemplo n.º 2
0
        public override IServiceProvider CreateServiceProvider(IServiceCollection services)
        {
            // This registers and initializes the Container with Prism ensuring
            // that both Shiny & Prism use the same container
            ContainerLocator.SetContainerExtension(() => new DryIocContainerExtension());
            var container = ContainerLocator.Container.GetContainer();

            DryIocAdapter.Populate(container, services);
            return(container.GetServiceProvider());
        }
Ejemplo n.º 3
0
        public override IServiceProvider CreateServiceProvider(IServiceCollection services)
        {
            var container = new Container(Rules
                                          .Default
                                          .WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient)
                                          .With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments))
                                          .WithFuncAndLazyWithoutRegistration()
                                          .WithTrackingDisposableTransients()
                                          .WithoutFastExpressionCompiler()
                                          .WithFactorySelector(Rules.SelectLastRegisteredFactory())
                                          );

            DryIocAdapter.Populate(container, services);
            Container = container;
            return(container.GetServiceProvider());
        }