Exemple #1
0
        public bool TryDemandMountPoint(Guid mountPointId, out IMountPoint mountPoint)
        {
            using (Timing.Over("Get mount point"))
            {
                MountPointInfo info;
                if (SettingsLoader.TryGetMountPoint(mountPointId, out info))
                {
                    return(TryDemandMountPoint(info, out mountPoint));
                }

                mountPoint = null;
                return(false);
            }
        }
Exemple #2
0
 public static void Scan(string templateDir)
 {
     foreach (IMountPointFactory factory in SettingsLoader.Components.OfType <IMountPointFactory>())
     {
         IMountPoint mountPoint;
         if (factory.TryMount(null, templateDir, out mountPoint))
         {
             foreach (IGenerator generator in SettingsLoader.Components.OfType <IGenerator>())
             {
                 foreach (ITemplate template in generator.GetTemplatesFromSource(mountPoint))
                 {
                     SettingsLoader.AddTemplate(template);
                     SettingsLoader.AddMountPoint(mountPoint);
                 }
             }
         }
     }
 }
        private static void WriteTemplateCacheForLocale(string locale)
        {
            bool isCurrentLocale = string.IsNullOrEmpty(locale) &&
                                   string.IsNullOrEmpty(EngineEnvironmentSettings.Host.Locale) ||
                                   (locale == EngineEnvironmentSettings.Host.Locale);

            IDictionary <string, ILocalizationLocator> locatorsForLocale;

            if (string.IsNullOrEmpty(locale) ||
                !_localizationMemoryCache.TryGetValue(locale, out locatorsForLocale))
            {
                locatorsForLocale = null;
            }

            List <TemplateInfo> existingTemplatesForLocale = LoadTemplateCacheForLocale(locale);

            if (existingTemplatesForLocale.Count == 0)
            {
                // the cache for this locale didn't exist previously. Start with the neutral locale as if it were the existing
                existingTemplatesForLocale = LoadTemplateCacheForLocale(null);
            }

            HashSet <string>    foundTemplates     = new HashSet <string>();
            List <TemplateInfo> mergedTemplateList = new List <TemplateInfo>();

            foreach (TemplateInfo template in NewTemplateInfoForLocale(locale))
            {
                mergedTemplateList.Add(template);
                foundTemplates.Add(template.Identity);
            }

            foreach (TemplateInfo templateInfo in existingTemplatesForLocale)
            {
                if (!foundTemplates.Contains(templateInfo.Identity))
                {
                    UpdateTemplateLocalization(templateInfo, locatorsForLocale);
                    mergedTemplateList.Add(templateInfo);
                    foundTemplates.Add(templateInfo.Identity);
                }
            }

            SettingsLoader.WriteTemplateCache(mergedTemplateList, locale, isCurrentLocale);
        }