private void UpdateTemplateListFromCache(TemplateCacheEx cache, ISet <ITemplateInfo> templates) { using (Timing.Over(EnvironmentSettings.Host, "Enumerate infos")) { templates.UnionWith(cache.TemplateInfo); } }
private void Save(TemplateCacheEx cacheToSave) { cacheToSave.WriteTemplateCaches(_userSettings.Version); _userSettings.SetVersionToCurrent(); var jObject = JObject.FromObject(_userSettings); _paths.WriteAllText(_paths.User.SettingsFile, jObject.ToString()); WriteInstallDescriptorCache(); if (_userTemplateCache != cacheToSave) { ReloadTemplates(); } }
public void RebuildCacheFromSettingsIfNotCurrent(bool forceRebuild) { EnsureLoaded(); var array = FindMountPointsToScan(forceRebuild).ToArray(); if (array.Any()) { var templateCache = new TemplateCacheEx(EnvironmentSettings); var array2 = array; foreach (var mountPointInfo in array2) { templateCache.Scan(mountPointInfo.Place); } Save(templateCache); ReloadTemplates(); } }
public TemplateSettingsLoader(IEngineEnvironmentSettings environmentSettings) { EnvironmentSettings = environmentSettings; _paths = new Paths(environmentSettings); _userTemplateCache = new TemplateCacheEx(environmentSettings); //string userProfilePath = EnvironmentSettings.Environment.GetEnvironmentVariable("USERPROFILE"); //string dotNetCliPath = Path.Combine(userProfilePath, ".templateengine", "dotnetcli"); //string[] directories = Directory.GetDirectories(dotNetCliPath); //if (directories != null && directories.Length > 0) //{ // int last = directories.Length - 1; // string targetDirectory = directories[last]; // if (_paths.Exists(targetDirectory)) // _userTemplateCache.Scan(targetDirectory); //} _installUnitDescriptorCache = new InstallUnitDescriptorCache(environmentSettings); }
private void EnsureTemplatesLoaded() { if (!_templatesLoaded) { string text; if (_paths.Exists(_paths.User.CurrentLocaleTemplateCacheFile)) { using (Timing.Over(EnvironmentSettings.Host, "Read template cache")) { text = _paths.ReadAllText(_paths.User.CurrentLocaleTemplateCacheFile, "{}"); } } else if (_paths.Exists(_paths.User.CultureNeutralTemplateCacheFile)) { using (Timing.Over(EnvironmentSettings.Host, "Clone cultural neutral cache")) { text = _paths.ReadAllText(_paths.User.CultureNeutralTemplateCacheFile, "{}"); _paths.WriteAllText(_paths.User.CurrentLocaleTemplateCacheFile, text); } } else { text = "{}"; } JObject parsed; using (Timing.Over(EnvironmentSettings.Host, "Parse template cache")) { parsed = JObject.Parse(text); } using (Timing.Over(EnvironmentSettings.Host, "Init template cache")) { _userTemplateCache = new TemplateCacheEx(EnvironmentSettings, parsed, _userSettings.Version); } _templatesLoaded = true; } }