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)); }
public void Discover(ShapeTableBuilder builder) { foreach (var featureDescriptor in _featureManager.GetEnabledFeaturesAsync().Result) { ProcessFeatureDescriptor(builder, featureDescriptor); } }
public async Task <int> GetFeatureHashAsync() { int serial; if (_memoryCache.TryGetValue(FeatureHashCacheKey, out serial)) { return(serial); } // Calculate a hash of all enabled features' name serial = (await _featureManager.GetEnabledFeaturesAsync()) .OrderBy(x => x.Name) .Aggregate(0, (a, f) => a * 7 + f.Name.GetHashCode()); var options = new MemoryCacheEntryOptions() .AddExpirationToken(_signal.GetToken(FeatureManager.FeatureManagerCacheKey)); _memoryCache.Set(FeatureHashCacheKey, serial, options); return(serial); }
public void Discover(ShapeTableBuilder builder) { if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Start discovering shapes"); } var harvesterInfos = _harvesters.Select(harvester => new { harvester, subPaths = harvester.SubPaths() }); var activeFeatures = _featureManager.GetEnabledFeaturesAsync().Result; var activeExtensions = Once(activeFeatures); var hits = activeExtensions.Select(extensionDescriptor => { if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Start discovering candidate views filenames"); } var matcher = new Matcher(); foreach(var extension in _shapeTemplateViewEngines.SelectMany(x => x.TemplateFileExtensions)) { matcher.AddInclude(string.Format("*.{0}", extension)); } var pathContexts = harvesterInfos.SelectMany(harvesterInfo => harvesterInfo.subPaths.Select(subPath => { var basePath = _fileSystem.Combine(extensionDescriptor.Location, extensionDescriptor.Id); var virtualPath = _fileSystem.Combine(basePath, subPath); var files = _fileSystem.ListFiles(virtualPath, matcher).ToReadOnlyCollection(); return new { harvesterInfo.harvester, basePath, subPath, virtualPath, files }; })).ToList(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Done discovering candidate views filenames"); } var fileContexts = pathContexts.SelectMany(pathContext => _shapeTemplateViewEngines.SelectMany(ve => { return pathContext.files.Select( file => new { fileName = Path.GetFileNameWithoutExtension(file.Name), fileVirtualPath = "~/" + _fileSystem.Combine(pathContext.virtualPath, file.Name), pathContext }); })); var shapeContexts = fileContexts.SelectMany(fileContext => { var harvestShapeInfo = new HarvestShapeInfo { SubPath = fileContext.pathContext.subPath, FileName = fileContext.fileName, TemplateVirtualPath = fileContext.fileVirtualPath }; var harvestShapeHits = fileContext.pathContext.harvester.HarvestShape(harvestShapeInfo); return harvestShapeHits.Select(harvestShapeHit => new { harvestShapeInfo, harvestShapeHit, fileContext }); }); return shapeContexts.Select(shapeContext => new { extensionDescriptor, shapeContext }).ToList(); }).SelectMany(hits2 => hits2); foreach (var iter in hits) { // templates are always associated with the namesake feature of module or theme var hit = iter; var featureDescriptors = iter.extensionDescriptor.Features.Where(fd => fd.Id == hit.extensionDescriptor.Id); foreach (var featureDescriptor in featureDescriptors) { if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Binding {0} as shape [{1}] for feature {2}", hit.shapeContext.harvestShapeInfo.TemplateVirtualPath, iter.shapeContext.harvestShapeHit.ShapeType, featureDescriptor.Id); } builder.Describe(iter.shapeContext.harvestShapeHit.ShapeType) .From(new Feature { Descriptor = featureDescriptor }) .BoundAs( hit.shapeContext.harvestShapeInfo.TemplateVirtualPath, shapeDescriptor => displayContext => RenderAsync(shapeDescriptor, displayContext, hit.shapeContext.harvestShapeInfo, hit.shapeContext.harvestShapeHit)); } } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Done discovering shapes"); } }