Exemplo n.º 1
0
 public string[] GetInstalledThemes()
 {
     return(extensionManager.AvailableExtensions()
            .Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType) && shellDescriptor.Features.Any(y => y.Name == x.Name))
            .Select(x => x.Name)
            .ToArray());
 }
        public void AvailableExtensionsShouldFollowCatalogLocations()
        {
            _folders.Manifests.Add("foo", "Name: Foo");
            _folders.Manifests.Add("bar", "Name: Bar");
            _folders.Manifests.Add("frap", "Name: Frap");
            _folders.Manifests.Add("quad", "Name: Quad");

            var available = _manager.AvailableExtensions();

            Assert.That(available.Count(), Is.EqualTo(4));
            Assert.That(available, Has.Some.Property("Id").EqualTo("foo"));
        }
        public void AvailableExtensionsShouldFollowCatalogLocations()
        {
            _folders.Manifests.Add("foo", "Name: Foo");
            _folders.Manifests.Add("bar", "Name: Bar");
            _folders.Manifests.Add("frap", "Name: Frap");
            _folders.Manifests.Add("quad", "Name: Quad");

            var available = _manager.AvailableExtensions();

            Assert.Equal(available.Count(), 4);
            Assert.Contains(available, t => t.Id == "foo");
        }
Exemplo n.º 4
0
        public ActionResult Index(ModulesIndexOptions options, PagerParameters pagerParameters)
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage modules")))
            {
                return(new HttpUnauthorizedResult());
            }

            Pager pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters);

            IEnumerable <ModuleEntry> modules = _extensionManager.AvailableExtensions()
                                                .Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType) &&

                                                       (string.IsNullOrEmpty(options.SearchText) || extensionDescriptor.Name.ToLowerInvariant().Contains(options.SearchText.ToLowerInvariant())))
                                                .OrderBy(extensionDescriptor => extensionDescriptor.Name)
                                                .Select(extensionDescriptor => new ModuleEntry {
                Descriptor = extensionDescriptor
            });

            int totalItemCount = modules.Count();

            if (pager.PageSize != 0)
            {
                modules = modules.Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize);
            }

            // This way we can more or less reliably handle this implicit dependency.
            var installModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null;

            modules = modules.ToList();
            foreach (ModuleEntry moduleEntry in modules)
            {
                moduleEntry.IsRecentlyInstalled = _moduleService.IsRecentlyInstalled(moduleEntry.Descriptor);
                moduleEntry.CanUninstall        = installModules;

                if (_extensionDisplayEventHandler != null)
                {
                    foreach (string notification in _extensionDisplayEventHandler.Displaying(moduleEntry.Descriptor, ControllerContext.RequestContext))
                    {
                        moduleEntry.Notifications.Add(notification);
                    }
                }
            }


            return(View(new ModulesIndexViewModel
            {
                Modules = modules,
                InstallModules = installModules,
                Options = options,
                Pager = Shape.Pager(pager).TotalItemCount(totalItemCount)
            }));
        }
        public PackageData Harvest(string extensionName)
        {
            ExtensionDescriptor extensionDescriptor = _extensionManager.AvailableExtensions().FirstOrDefault(x => x.Id == extensionName);

            if (extensionDescriptor == null)
            {
                return(null);
            }
            return(new PackageData {
                ExtensionType = extensionDescriptor.ExtensionType,
                ExtensionName = extensionDescriptor.Id,
                ExtensionVersion = extensionDescriptor.Version,
                PackageStream = _packageBuilder.BuildPackage(extensionDescriptor),
            });
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Index()
        {
            IEnumerable <ModuleEntry> modules = _extensionManager.AvailableExtensions()
                                                .Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType))
                                                .OrderBy(extensionDescriptor => extensionDescriptor.Name)
                                                .Select(extensionDescriptor => new ModuleEntry {
                Descriptor = extensionDescriptor
            });

            var features = await _featureManager.GetEnabledFeaturesAsync();

            var installModules = features.FirstOrDefault(f => f.Id == "PackagingServices") != null;

            modules = modules.ToList();
            foreach (ModuleEntry moduleEntry in modules)
            {
                moduleEntry.IsRecentlyInstalled = false; //_moduleService.IsRecentlyInstalled(moduleEntry.Descriptor);
                moduleEntry.CanUninstall        = installModules;

                //if (_extensionDisplayEventHandler != null)
                //{
                //    foreach (string notification in _extensionDisplayEventHandler.Displaying(moduleEntry.Descriptor, ControllerContext.RequestContext))
                //    {
                //        moduleEntry.Notifications.Add(notification);
                //    }
                //}
            }

            var model = new ModulesIndexViewModel {
                Modules        = modules,
                InstallModules = installModules
            };

            return(View(model));
        }
Exemplo n.º 7
0
        private IEnumerable <UpdatePackageEntry> GetPackagesWorker(PackagingSource packagingSource)
        {
            var list = new Dictionary <string, UpdatePackageEntry>(StringComparer.OrdinalIgnoreCase);

            var extensions = _extensionManager.AvailableExtensions();

            foreach (var extension in extensions)
            {
                var packageId = PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType);

                GetOrAddEntry(list, packageId).ExtensionsDescriptor = extension;
            }

            var packages = _packagingSourceManager.GetExtensionList(false, packagingSource)
                           .ToList()
                           .GroupBy(p => p.PackageId, StringComparer.OrdinalIgnoreCase);

            foreach (var package in packages)
            {
                var entry = GetOrAddEntry(list, package.Key);
                entry.PackageVersions = entry.PackageVersions.Concat(package).ToList();
            }

            return(list.Values.Where(e => e.ExtensionsDescriptor != null && e.PackageVersions.Any()));
        }
        public void ExtensionManagerShouldLoadFeatures()
        {
            var extensionLoader = new StubLoaders();
            var folders         = new StubExtensionLocator();

            folders.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
    TestModule: 
        Description: My test module for Orchard.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(folders, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features);

            var features = extensionManager.LoadFeatures(testFeature);
            var types    = features.SelectMany(x => x.ExportedTypes);

            Assert.NotEqual(0, types.Count());
        }
        public void ExtensionManagerLoadFeatureReturnsTypesFromSpecificFeaturesWithFeatureAttribute()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders();

            extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
    TestModule: 
        Description: My test module for Orchard.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features)
                              .Single(x => x.Id == "TestFeature");

            foreach (var feature in extensionManager.LoadFeatures(new[] { testFeature }))
            {
                foreach (var type in feature.ExportedTypes)
                {
                    Assert.That(type == typeof(Phi));
                }
            }
        }
        public void ExtensionManagerFeaturesContainNonAbstractClasses()
        {
            var extensionLoader = new StubLoaders();
            var folders         = new StubExtensionLocator();

            folders.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
    TestModule: 
        Description: My test module for Orchard.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(folders, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features);

            var features = extensionManager.LoadFeatures(testFeature);
            var types    = features.SelectMany(x => x.ExportedTypes);

            foreach (var type in types)
            {
                Assert.True(type.GetTypeInfo().IsClass);
                Assert.True(!type.GetTypeInfo().IsAbstract);
            }
        }
        public void ExtensionManagerLoadFeatureDoesNotReturnTypesFromNonMatchingFeatures()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders(DefaultExtensionTypes.Module);

            extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
SystemVersion: 1
Features:
    TestModule: 
        Description: My test module for System.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var testModule = extensionManager.AvailableExtensions()
                             .SelectMany(x => x.Features)
                             .Single(x => x.Id == "TestModule");

            foreach (var feature in extensionManager.LoadFeatures(new[] { testModule }))
            {
                foreach (var type in feature.ExportedTypes)
                {
                    Assert.True(type != typeof(Phi));
                    Assert.True((type == typeof(Alpha) || (type == typeof(Beta))));
                }
            }
        }
        public void ExtensionManagerFeaturesContainNonAbstractClasses()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders(DefaultExtensionTypes.Module);

            extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
SystemVersion: 1
Features:
    TestModule: 
        Description: My test module for System.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features);

            var features = extensionManager.LoadFeatures(testFeature);
            var types    = features.SelectMany(x => x.ExportedTypes);

            foreach (var type in types)
            {
                Assert.True(type.IsClass);
                Assert.True(!type.IsAbstract);
            }
        }
        public void ExtensionManagerTestFeatureAttribute()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders(DefaultExtensionTypes.Module);

            extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
SystemVersion: 1
Features:
    TestModule: 
        Description: My test module for System.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features)
                              .Single(x => x.Id == "TestFeature");

            foreach (var feature in extensionManager.LoadFeatures(new[] { testFeature }))
            {
                foreach (var type in feature.ExportedTypes)
                {
                    foreach (SystemFeatureAttribute featureAttribute in type.GetCustomAttributes(typeof(SystemFeatureAttribute), false))
                    {
                        Assert.Equal(featureAttribute.FeatureName, "TestFeature");
                    }
                }
            }
        }
Exemplo n.º 14
0
 private bool ModuleAlreadyInstalled(string packageId)
 {
     return(_extensionManager.AvailableExtensions().Where(m => DefaultExtensionTypes.IsModule(m.ExtensionType))
            .Any(module => module.Id.Equals(
                     packageId.Substring(PackagingSourceManager.GetExtensionPrefix(DefaultExtensionTypes.Module).Length),
                     StringComparison.OrdinalIgnoreCase)));
 }
        public void ExtensionManagerShouldLoadFeatures()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders(DefaultExtensionTypes.Module);

            extensionFolder.Manifests.Add("TestModule", @"
Name: TestModule
Version: 1.0.3
SystemVersion: 1
Features:
    TestModule: 
        Description: My test module for System.
    TestFeature:
        Description: Contains the Phi type.
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var testFeature = extensionManager.AvailableExtensions()
                              .SelectMany(x => x.Features);

            var features = extensionManager.LoadFeatures(testFeature);
            var types    = features.SelectMany(x => x.ExportedTypes);

            Assert.NotEqual(types.Count(), 0);
        }
Exemplo n.º 16
0
 public IEnumerable <ExtensionInfo> AvailableExtensions()
 {
     return(_extensionManager.AvailableExtensions().Select(t => new ExtensionInfo()
     {
         Name = t.Name
     }));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Retrieves an enumeration of the available features together with its state (enabled / disabled).
        /// </summary>
        /// <returns>An enumeration of the available features together with its state (enabled / disabled).</returns>
        public IEnumerable <ModuleFeature> GetAvailableFeatures()
        {
            var enabledFeatures = _shellDescriptorManager.GetShellDescriptor().Features;

            return(_extensionManager.AvailableExtensions()
                   .SelectMany(m => _extensionManager.LoadFeatures(m.Features))
                   .Select(f => AssembleModuleFromDescriptor(f, enabledFeatures
                                                             .FirstOrDefault(sf => string.Equals(sf.Name, f.Descriptor.Id, StringComparison.OrdinalIgnoreCase)) != null)));
        }
Exemplo n.º 18
0
        public ActionResult Create()
        {
            if (!CheckPermission(PagesPermissions.ManagePages))
            {
                return(new HttpUnauthorizedResult());
            }

            WorkContext.Breadcrumbs.Add(T("Pages"), Url.Action("Index", new { area = Constants.Areas.Pages }));
            WorkContext.Breadcrumbs.Add(T("Create"));

            var model = new PageModel {
                IsEnabled = true, Title = ""
            };

            var result = new ControlFormResult <PageModel>(model)
            {
                Title                = T("Create Page").Text,
                UpdateActionName     = "Update",
                CssClass             = "form-edit-page",
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            //result.AddAction(true, false, false).HasText(T("Preview")).HasUrl(Url.Action("Preview")).HasButtonStyle(ButtonStyle.Default);

            var themes = extensionManager.AvailableExtensions().Where(x => DefaultExtensionTypes.IsTheme(x.ExtensionType) && descriptor.Features.Any(f => f.Name == x.Id)).ToDictionary(k => k.Id, v => v.Name);

            result.RegisterExternalDataSource(x => x.Theme, themes);
            result.RegisterExternalDataSource(x => x.ShowOnMenuId, menuService.GetRecords().ToDictionary(k => k.Id, v => v.Name));

            // Page tags
            var tags = pageTagService.GetRecords();

            if (tags.Count > 0)
            {
                result.AddHiddenValue("RichtextCustomTags", JsonConvert.SerializeObject(tags.Select(x => new[] { x.Name, "[%" + x.Name + "%]" })));
            }

            return(result);
        }
Exemplo n.º 19
0
        public override IQueryable <IPackage> GetPackages()
        {
            IEnumerable <IPackage> repositoryPackages = SourceRepository.GetPackages().ToList();
            IEnumerable <IPackage> packages           = from extension in _extensionManager.AvailableExtensions()
                                                        let id = PackageBuilder.BuildPackageId(extension.Id, extension.ExtensionType)
                                                                 let version = extension.Version != null?Version.Parse(extension.Version) : null
                                                                                   let package = repositoryPackages.FirstOrDefault(p => p.Id == id && (version == null || p.Version == version))
                                                                                                     where package != null
                                                                                                 select package;

            return(packages.AsQueryable());
        }
Exemplo n.º 20
0
        public void List()
        {
            var currentTheme           = _siteThemeService.GetSiteTheme();
            var featuresThatNeedUpdate = _dataMigrationManager.GetFeaturesThatNeedUpdate();

            var themes = _extensionManager.AvailableExtensions()
                         .Where(d => DefaultExtensionTypes.IsTheme(d.ExtensionType))
                         .Where(d => d.Tags != null && d.Tags.Split(',').Any(t => t.Trim().Equals("hidden", StringComparison.OrdinalIgnoreCase)) == false)
                         .Select(d => new ThemeEntry {
                Descriptor  = d,
                NeedsUpdate = featuresThatNeedUpdate.Contains(d.Id),
                Enabled     = _shellDescriptor.Features.Any(sf => sf.Name == d.Id)
            })
                         .ToArray();

            if (Summary)
            {
                foreach (var theme in themes)
                {
                    Context.Output.WriteLine(T("{0}", theme.Name));
                }
            }
            else
            {
                Context.Output.WriteLine(T("Current theme"));
                Context.Output.WriteLine(T("--------------------------"));
                WriteThemeLines(new ThemeEntry {
                    Descriptor  = currentTheme,
                    NeedsUpdate = featuresThatNeedUpdate.Contains(currentTheme.Id),
                    Enabled     = _shellDescriptor.Features.Any(sf => sf.Name == currentTheme.Id)
                });

                Context.Output.WriteLine(T("List of available themes"));
                Context.Output.WriteLine(T("--------------------------"));
                themes.Where(t => t.Name.Trim().Equals(currentTheme.Name.Trim(), StringComparison.OrdinalIgnoreCase) == false)
                .ToList()
                .ForEach(WriteThemeLines);
            }
        }
Exemplo n.º 21
0
        public ActionResult Index(ModulesIndexOptions options, PagerParameters pagerParameters)
        {
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to manage modules")))
            {
                return(new HttpUnauthorizedResult());
            }

            Pager pager = new Pager(Services.WorkContext.CurrentSite, pagerParameters);

            IEnumerable <ModuleEntry> modules = _extensionManager.AvailableExtensions()
                                                .Where(extensionDescriptor => DefaultExtensionTypes.IsModule(extensionDescriptor.ExtensionType) &&
                                                       (string.IsNullOrEmpty(options.SearchText) || extensionDescriptor.Name.ToLowerInvariant().Contains(options.SearchText.ToLowerInvariant())))
                                                .OrderBy(extensionDescriptor => extensionDescriptor.Name)
                                                .Select(extensionDescriptor => new ModuleEntry {
                Descriptor = extensionDescriptor
            });

            int totalItemCount = modules.Count();

            if (pager.PageSize != 0)
            {
                modules = modules.Skip((pager.Page - 1) * pager.PageSize).Take(pager.PageSize);
            }

            modules = modules.ToList();
            foreach (ModuleEntry moduleEntry in modules)
            {
                moduleEntry.IsRecentlyInstalled = _moduleService.IsRecentlyInstalled(moduleEntry.Descriptor);
            }

            return(View(new ModulesIndexViewModel {
                Modules = modules,
                InstallModules = _featureManager.GetEnabledFeatures().FirstOrDefault(f => f.Id == "PackagingServices") != null,
                Options = options,
                Pager = Shape.Pager(pager).TotalItemCount(totalItemCount)
            }));
        }
Exemplo n.º 22
0
        public void MonitorExtensionsWork(Action <IVolatileToken> monitor)
        {
            var locations = _extensionManager.AvailableExtensions().Select(e => e.Location).Distinct(StringComparer.InvariantCultureIgnoreCase);

            Logger.Information("Start monitoring extension files...");
            // Monitor add/remove of any module/theme
            foreach (string location in locations)
            {
                Logger.Debug("Monitoring virtual path \"{0}\"", location);
                monitor(_virtualPathMonitor.WhenPathChanges(location));
            }

            // Give loaders a chance to monitor any additional changes
            var extensions = _extensionManager.AvailableExtensions().Where(d => DefaultExtensionTypes.IsModule(d.ExtensionType) || DefaultExtensionTypes.IsTheme(d.ExtensionType)).ToList();

            foreach (var extension in extensions)
            {
                foreach (var loader in _loaders)
                {
                    loader.Monitor(extension, monitor);
                }
            }
            Logger.Information("Done monitoring extension files...");
        }
Exemplo n.º 23
0
        public ActionResult Index() {
            if (!Services.Authorizer.Authorize(Orchard.Themes.Permissions.ApplyTheme, T("Cannot manage themes")))
                return new HttpUnauthorizedResult();

            var viewModel = new ThemePickerIndexViewModel {
                ThemeSelectionSettings = _settingsService.Get(),
                ThemeSelectionRules = _rules.Select(r => r.GetType().Name),
                Themes = _extensionManager.AvailableExtensions()
                    .Where(d => DefaultExtensionTypes.IsTheme(d.ExtensionType) &&
                                _shellDescriptor.Features.Any(sf => sf.Name == d.Id))
                    .Select(d => d.Id)
                    .OrderBy(n => n)
            };

            return View(viewModel);
        }
Exemplo n.º 24
0
        public IEnumerable <Recipe> Recipes()
        {
            if (_recipes == null)
            {
                var recipes = new List <Recipe>();

                foreach (var extension in _extensionManager.AvailableExtensions())
                {
                    recipes.AddRange(_recipeHarvester.HarvestRecipes(extension.Id).Where(recipe => recipe.IsSetupRecipe));
                }

                _recipes = recipes;
            }

            return(_recipes);
        }
        public void ThemeNameIsIntroducedAsFeatureImplicitly()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders(DefaultExtensionTypes.Theme);

            extensionFolder.Manifests.Add("Minimalistic", @"
Name: Minimalistic
Version: 1.0.3
SystemVersion: 1
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var minimalisticModule             = extensionManager.AvailableExtensions().Single(x => x.Id == "Minimalistic");

            Assert.Equal(minimalisticModule.Features.Count(), 1);
            Assert.Equal(minimalisticModule.Features.Single().Id, "Minimalistic");
        }
Exemplo n.º 26
0
        public async Task <IEnumerable <INavigationDefinition> > Filter(IEnumerable <INavigationDefinition> navigationDefinitions)
        {
            foreach (var navDef in navigationDefinitions)
            {
                var areaName = extensionManager.AvailableExtensions()
                               .FirstOrDefault(e => e.Id == navDef.GetType().Assembly.FullName).Name;
                foreach (var navItem in navDef.Items)
                {
                    if (!navItem.RouteValues.ContainsKey(RouteConst.area))
                    {
                        navItem.RouteValues[RouteConst.area] = areaName;
                    }
                }
            }

            return(navigationDefinitions);
        }
        public void ModuleNameIsIntroducedAsFeatureImplicitly()
        {
            var extensionLoader = new StubLoaders();
            var extensionFolder = new StubFolders();

            extensionFolder.Manifests.Add("Minimalistic", @"
Name: Minimalistic
Version: 1.0.3
OrchardVersion: 1
");

            IExtensionManager extensionManager = CreateExtensionManager(extensionFolder, extensionLoader);
            var minimalisticModule             = extensionManager.AvailableExtensions().Single(x => x.Id == "Minimalistic");

            Assert.That(minimalisticModule.Features.Count(), Is.EqualTo(1));
            Assert.That(minimalisticModule.Features.Single().Id, Is.EqualTo("Minimalistic"));
        }
Exemplo n.º 28
0
        public bool HasLoader(string featureId)
        {
            var descriptor = _extensionManager
                             .AvailableExtensions()
                             .Where(d => DefaultExtensionTypes.IsModule(d.ExtensionType) || DefaultExtensionTypes.IsTheme(d.ExtensionType))
                             .OrderBy(d => d.Id)
                             .FirstOrDefault(e => e.Id == featureId || e.Features.Select(f => f.Id).Contains(featureId));

            foreach (var loader in _loaders)
            {
                if (loader.LoaderIsSuitable(descriptor))
                {
                    return(true);
                }
            }

            return(false);
        }
        public ActionResult Import()
        {
            if (!Services.Authorizer.Authorize(Permissions.UploadTranslation))
            {
                return(RedirectToAction("Index"));
            }
            var model = _localizationService.GetCultures();

            var extensions = _extensionManager.AvailableExtensions();

            ViewBag.Modules = extensions
                              .Where(e => DefaultExtensionTypes.IsModule(e.ExtensionType))
                              .OrderBy(e => e.Name);
            ViewBag.Themes = extensions
                             .Where(extensionDescriptor => DefaultExtensionTypes.IsTheme(extensionDescriptor.ExtensionType))
                             .OrderBy(e => e.Name);
            return(View(model));
        }
Exemplo n.º 30
0
        public void MonitorExtensionsWork(Action <IVolatileToken> monitor)
        {
            Logger.Information("Start monitoring extension files...");
            // Monitor add/remove of any module/theme
            monitor(_virtualPathMonitor.WhenPathChanges("~/Modules"));
            monitor(_virtualPathMonitor.WhenPathChanges("~/Themes"));

            // Give loaders a chance to monitor any additional changes
            var extensions = _extensionManager.AvailableExtensions().Where(d => DefaultExtensionTypes.IsModule(d.ExtensionType) || DefaultExtensionTypes.IsTheme(d.ExtensionType)).ToList();

            foreach (var extension in extensions)
            {
                foreach (var loader in _loaders)
                {
                    loader.Monitor(extension, monitor);
                }
            }
            Logger.Information("Done monitoring extension files...");
        }