Contains the information necessary to initialize an IoC container for a particular tenant. This model is created by the ICompositionStrategy and is passed into the IShellContainerFactory.
        public SessionFactoryHolderFactory(
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IDataServicesProviderFactory dataServicesProviderFactory,
            IAppDataFolder appDataFolder,
            ISessionConfigurationCache sessionConfigurationCache,
            IHostEnvironment hostEnvironment,
            IDatabaseCacheConfiguration cacheConfiguration,
            Func<IEnumerable<ISessionConfigurationEvents>> configurers,
            IRepository<ConnectionsRecord> connectionsRecordRepository,
            IEncryptionService encryptionService,
            ICacheManager cacheManager)
        {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _dataServicesProviderFactory = dataServicesProviderFactory;
            _appDataFolder = appDataFolder;
            _sessionConfigurationCache = sessionConfigurationCache;
            _hostEnvironment = hostEnvironment;
            _cacheConfiguration = cacheConfiguration;
            _configurers = configurers;
            _connectionsRecordRepository = connectionsRecordRepository;
            _encryptionService = encryptionService;
            _cacheManager = cacheManager;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
コード例 #2
0
 public ContentPartRecordsForm(
     ShellBlueprint shellBlueprint,
     IShapeFactory shapeFactory) {
     _shellBlueprint = shellBlueprint;
     Shape = shapeFactory;
     T = NullLocalizer.Instance;
 }
        public void ExtensionDisplayNameShouldBeUsedInBothStandardRoutes() {
            var blueprint = new ShellBlueprint {
                Controllers = new[] {
                    new ControllerBlueprint {
                        AreaName ="Long.Name.Foo",
                        Feature =new Feature {
                            Descriptor=new FeatureDescriptor {
                                Extension=new ExtensionDescriptor {
                                    Id="Foo",
                                    Name="A Foo Module",
                                    Path="Foo"
                                }
                            }
                        }
                    },
                    new ControllerBlueprint {
                        AreaName ="Long.Name.Bar",
                        Feature =new Feature {
                            Descriptor=new FeatureDescriptor {
                                Extension=new ExtensionDescriptor {
                                    Id="Bar",
                                    Name="Bar",
                                    Path="BarBar"
                                }
                            }
                        }
                    }
                }
            };
            var routeProvider = new StandardExtensionRouteProvider(blueprint);

            var routes = new List<RouteDescriptor>();
            routeProvider.GetRoutes(routes);

            Assert.That(routes, Has.Count.EqualTo(4));
            var fooAdmin = routes.Select(x => x.Route).OfType<Route>()
                .Single(x => x.Url == "Admin/Foo/{action}/{id}");
            var fooRoute = routes.Select(x => x.Route).OfType<Route>()
                .Single(x => x.Url == "Foo/{controller}/{action}/{id}");
            var barAdmin = routes.Select(x => x.Route).OfType<Route>()
                .Single(x => x.Url == "Admin/BarBar/{action}/{id}");
            var barRoute = routes.Select(x => x.Route).OfType<Route>()
                .Single(x => x.Url == "BarBar/{controller}/{action}/{id}");

            Assert.That(fooAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Foo"));
            Assert.That(fooRoute.DataTokens["area"], Is.EqualTo("Long.Name.Foo"));
            Assert.That(barAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Bar"));
            Assert.That(barRoute.DataTokens["area"], Is.EqualTo("Long.Name.Bar"));
        }
コード例 #4
0
        public ModuleGeneratorService(
            IOrchardServices orchardServices,
            IContentManager contentManager,
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IAppDataFolder appDataFolder)
        {
            _orchardServices = orchardServices;
            _contentManager = contentManager;
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _appDataFolder = appDataFolder;

            Logger = NullLogger.Instance;
        }
コード例 #5
0
        public void NormalExecutionReturnsExpectedObjects() {
            var settings = new ShellSettings { Name = ShellSettings.DefaultName };
            var descriptor = new ShellDescriptor { SerialNumber = 6655321 };
            var blueprint = new ShellBlueprint();
            var shellLifetimeScope = _container.BeginLifetimeScope("shell");
            var httpContext = new StubHttpContext();

            _container.Mock<IShellDescriptorCache>()
                .Setup(x => x.Fetch(ShellSettings.DefaultName))
                .Returns(descriptor);

            _container.Mock<ICompositionStrategy>()
                .Setup(x => x.Compose(settings, descriptor))
                .Returns(blueprint);

            _container.Mock<IShellContainerFactory>()
                .Setup(x => x.CreateContainer(settings, blueprint))
                .Returns(shellLifetimeScope);

            _container.Mock<IShellDescriptorManager>()
                .Setup(x => x.GetShellDescriptor())
                .Returns(descriptor);

            _container.Mock<IWorkContextEvents>()
                .Setup(x => x.Started());

            _container.Mock<IHttpContextAccessor>()
                .Setup(x => x.Current())
                .Returns(httpContext);

            _container.Mock<IHttpContextAccessor>()
                .Setup(x => x.CreateContext(It.IsAny<ILifetimeScope>()))
                .Returns(httpContext);

            var factory = _container.Resolve<IShellContextFactory>();

            var context = factory.CreateShellContext(settings);

            Assert.That(context.Settings, Is.SameAs(settings));
            Assert.That(context.Descriptor, Is.SameAs(descriptor));
            Assert.That(context.Blueprint, Is.SameAs(blueprint));
            Assert.That(context.LifetimeScope, Is.SameAs(shellLifetimeScope));
            Assert.That(context.Shell, Is.SameAs(shellLifetimeScope.Resolve<IOrchardShell>()));
        }
コード例 #6
0
        public AdminController(
            IOrchardServices orchardServices,
            IContentManager contentManager,
            IModuleGeneratorService moduleGeneratorService,
            IZipFileService zipFileService,
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IAppDataFolder appDataFolder)
        {
            _orchardServices = orchardServices;
            _contentManager = contentManager;
            _moduleGeneratorService = moduleGeneratorService;
            _zipFileService = zipFileService;
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _appDataFolder = appDataFolder;

            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;
        }
コード例 #7
0
        public void CreatingSetupContextUsesOrchardSetupFeature() {
            var settings = default(ShellSettings);
            var descriptor = default(ShellDescriptor);
            var blueprint = new ShellBlueprint();

            _container.Mock<ICompositionStrategy>()
                .Setup(x => x.Compose(It.IsAny<ShellSettings>(), It.IsAny<ShellDescriptor>()))
                .Callback((ShellSettings s, ShellDescriptor d) => {
                    settings = s;
                    descriptor = d;
                })
                .Returns(blueprint);

            _container.Mock<IShellContainerFactory>()
                .Setup(x => x.CreateContainer(It.IsAny<ShellSettings>(), blueprint))
                .Returns(_container.BeginLifetimeScope("shell"));

            var factory = _container.Resolve<IShellContextFactory>();
            var context = factory.CreateSetupContext(new ShellSettings { Name = ShellSettings.DefaultName });

            Assert.That(context.Descriptor.Features, Has.Some.With.Property("Name").EqualTo("Orchard.Setup"));
        }
コード例 #8
0
        public ILifetimeScope CreateContainer(ShellSettings settings, ShellBlueprint blueprint) {
            var intermediateScope = _lifetimeScope.BeginLifetimeScope(
                builder => {
                    foreach (var item in blueprint.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
                        var registration = RegisterType(builder, item)
                            .Keyed<IModule>(item.Type)
                            .InstancePerDependency();

                        foreach (var parameter in item.Parameters) {
                            registration = registration
                                .WithParameter(parameter.Name, parameter.Value)
                                .WithProperty(parameter.Name, parameter.Value);
                        }
                    }
                });

            return intermediateScope.BeginLifetimeScope(
                "shell",
                builder => {
                    var dynamicProxyContext = new DynamicProxyContext();

                    builder.Register(ctx => dynamicProxyContext);
                    builder.Register(ctx => settings);
                    builder.Register(ctx => blueprint.Descriptor);
                    builder.Register(ctx => blueprint);

                    var moduleIndex = intermediateScope.Resolve<IIndex<Type, IModule>>();
                    foreach (var item in blueprint.Dependencies.Where(t => typeof(IModule).IsAssignableFrom(t.Type))) {
                        builder.RegisterModule(moduleIndex[item.Type]);
                    }

                    foreach (var item in blueprint.Dependencies.Where(t => typeof(IDependency).IsAssignableFrom(t.Type))) {
                        var registration = RegisterType(builder, item)
                            .EnableDynamicProxy(dynamicProxyContext)
                            .InstancePerLifetimeScope();

                        foreach (var interfaceType in item.Type.GetInterfaces()
                            .Where(itf => typeof(IDependency).IsAssignableFrom(itf)
                                      && !typeof(IEventHandler).IsAssignableFrom(itf))) {
                            registration = registration.As(interfaceType);
                            if (typeof(ISingletonDependency).IsAssignableFrom(interfaceType)) {
                                registration = registration.InstancePerMatchingLifetimeScope("shell");
                            }
                            else if (typeof(IUnitOfWorkDependency).IsAssignableFrom(interfaceType)) {
                                registration = registration.InstancePerMatchingLifetimeScope("work");
                            }
                            else if (typeof(ITransientDependency).IsAssignableFrom(interfaceType)) {
                                registration = registration.InstancePerDependency();
                            }
                        }

                        if (typeof(IEventHandler).IsAssignableFrom(item.Type)) {
                            var interfaces = item.Type.GetInterfaces();
                            foreach (var interfaceType in interfaces) {

                                // register named instance for each interface, for efficient filtering inside event bus
                                // IEventHandler derived classes only
                                if (interfaceType.GetInterface(typeof (IEventHandler).Name) != null) {
                                    registration = registration.Named<IEventHandler>(interfaceType.Name);
                                }
                            }
                        }

                        foreach (var parameter in item.Parameters) {
                            registration = registration
                                .WithParameter(parameter.Name, parameter.Value)
                                .WithProperty(parameter.Name, parameter.Value);
                        }
                    }

                    foreach (var item in blueprint.Controllers) {
                        var serviceKeyName = (item.AreaName + "/" + item.ControllerName).ToLowerInvariant();
                        var serviceKeyType = item.Type;
                        RegisterType(builder, item)
                            .EnableDynamicProxy(dynamicProxyContext)
                            .Keyed<IController>(serviceKeyName)
                            .Keyed<IController>(serviceKeyType)
                            .WithMetadata("ControllerType", item.Type)
                            .InstancePerDependency()
                            ;
                    }

                    foreach (var item in blueprint.HttpControllers) {
                        var serviceKeyName = (item.AreaName + "/" + item.ControllerName).ToLowerInvariant();
                        var serviceKeyType = item.Type;
                        RegisterType(builder, item)
                            .EnableDynamicProxy(dynamicProxyContext)
                            .Keyed<IHttpController>(serviceKeyName)
                            .Keyed<IHttpController>(serviceKeyType)
                            .WithMetadata("ControllerType", item.Type)
                            .InstancePerDependency();
                    }

                    // Register code-only registrations specific to a shell
                    _shellContainerRegistrations.Registrations(builder);

                    var optionalShellByNameConfig = HostingEnvironment.MapPath("~/Config/Sites." + settings.Name + ".config");
                    if (File.Exists(optionalShellByNameConfig)) {
                        builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReaderConstants.DefaultSectionName, optionalShellByNameConfig));
                    }
                    else {
                        var optionalShellConfig = HostingEnvironment.MapPath("~/Config/Sites.config");
                        if (File.Exists(optionalShellConfig))
                            builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReaderConstants.DefaultSectionName, optionalShellConfig));
                    }
                });
        }
コード例 #9
0
ファイル: Routes.cs プロジェクト: Higea/Orchard
 public Routes(ShellBlueprint blueprint, IAliasHolder aliasHolder) {
     _blueprint = blueprint;
     _aliasHolder = aliasHolder;
 }
コード例 #10
0
ファイル: Routes.cs プロジェクト: jgtaveras/Coevery
 public Routes(ShellBlueprint blueprint) {
     _blueprint = blueprint;
 }
コード例 #11
0
 public StandardExtensionRouteProvider(ShellBlueprint blueprint) {
     _blueprint = blueprint;
 }
コード例 #12
-1
        public CustomSessionFactoryHolder(
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IDataServicesProviderFactory dataServicesProviderFactory,
            IAppDataFolder appDataFolder,
            ISessionConfigurationCache sessionConfigurationCache,
            IHostEnvironment hostEnvironment,
            IDatabaseCacheConfiguration cacheConfiguration,
            Func<IEnumerable<ISessionConfigurationEvents>> configurers,
            string provider,
            string connectionString
            )
        {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _dataServicesProviderFactory = dataServicesProviderFactory;
            _appDataFolder = appDataFolder;
            _sessionConfigurationCache = sessionConfigurationCache;
            _hostEnvironment = hostEnvironment;
            _cacheConfiguration = cacheConfiguration;
            _configurers = configurers;

            _provider = provider;
            _connectionString = connectionString;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
コード例 #13
-1
        public SessionConfigurationCache(ShellSettings shellSettings, ShellBlueprint shellBlueprint, IAppDataFolder appDataFolder, IHostEnvironment hostEnvironment) {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _appDataFolder = appDataFolder;
            _hostEnvironment = hostEnvironment;
            _currentConfig = null;

            Logger = NullLogger.Instance;
        }
コード例 #14
-1
        public SessionFactoryHolder(
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IDataServicesProviderFactory dataServicesProviderFactory,
            IAppDataFolder appDataFolder,
            ISessionConfigurationCache sessionConfigurationCache,
            IHostEnvironment hostEnvironment) {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _dataServicesProviderFactory = dataServicesProviderFactory;
            _appDataFolder = appDataFolder;
            _sessionConfigurationCache = sessionConfigurationCache;
            _hostEnvironment = hostEnvironment;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }