private string[] GetAllLocalizationFiles(string searchPattern, string localizationsFolder) { var files = new List <string>(); // Get platform localization files var platformPath = _hostingEnv.MapPath("~/"); var platformFileNames = GetFilesByPath(platformPath, searchPattern, localizationsFolder); files.AddRange(platformFileNames); // Get modules localization files ordered by dependency. var allModules = _moduleCatalog.Modules.OfType <ManifestModuleInfo>().ToArray(); var manifestModules = _moduleCatalog.CompleteListWithDependencies(allModules) .Where(x => x.State == ModuleState.Initialized) .OfType <ManifestModuleInfo>(); foreach (var module in manifestModules) { if (!string.IsNullOrEmpty(module.FullPhysicalPath)) { var moduleFileNames = GetFilesByPath(module.FullPhysicalPath, searchPattern, localizationsFolder); files.AddRange(moduleFileNames); } } // Get user defined localization files from App_Data/Localizations folder var userLocalizationPath = _hostingEnv.MapPath("~/App_Data"); var userFileNames = GetFilesByPath(userLocalizationPath, searchPattern, localizationsFolder); files.AddRange(userFileNames); return(files.ToArray()); }
public override void Process(TagHelperContext context, TagHelperOutput output) { output.TagName = null; //It is very important to use CompleteListWithDependencies, because of this method returns modules that are sorted according to their dependencies (Topological sort) //and this keep the proper order for scripts includes on the index page. var sucesfullyLoadedModules = _localModuleCatalog.CompleteListWithDependencies(_localModuleCatalog.Modules).OfType <ManifestModuleInfo>().Where(x => x.State == ModuleState.Initialized && x.Errors.IsNullOrEmpty()); foreach (var module in sucesfullyLoadedModules) { var normalizedBundlePath = BundlePath.Replace("~/", "").Replace("\\", "/").TrimStart('/'); var moduleBundleVirtualPath = $"/Modules/$({module.ModuleName})/{normalizedBundlePath}"; var bundlePhysicalPath = Path.Combine(module.FullPhysicalPath, normalizedBundlePath); if (File.Exists(bundlePhysicalPath)) { string version = null; if (AppendVersion) { EnsureFileVersionProvider(); version = _fileVersionProvider.GetFileVersionHash(bundlePhysicalPath); } var tagBuilder = GetTagBuilder(moduleBundleVirtualPath, version); output.Content.AppendHtml(tagBuilder); output.Content.AppendHtml(Environment.NewLine); } } }