/// <summary>
        /// Gets prefix for semantic vocabulary.
        /// </summary>
        /// <param name="vocab">Vocabulary name</param>
        /// <param name="loc">The localization</param>
        /// <returns>Prefix for this semantic vocabulary</returns>
        public static string GetPrefix(string vocab, Localization loc)
        {
            string key = loc.LocalizationId;

            if (!_semanticVocabularies.ContainsKey(key) || SiteConfiguration.CheckSettingsNeedRefresh(_vocabSettingsType, loc))
            {
                LoadVocabulariesForLocalization(loc);
            }
            if (_semanticVocabularies.ContainsKey(key))
            {
                List <SemanticVocabulary> vocabs = _semanticVocabularies[key];
                return(GetPrefix(vocabs, vocab));
            }
            Log.Error("Localization {0} does not contain vocabulary {1}. Check that the Publish Settings page is published and the application cache is up to date.", loc.LocalizationId, vocab);
            return(null);
        }
Пример #2
0
        public IDictionary Resources(Localization localization)
        {
            string key = localization.LocalizationId;

            //Load resources if they are not already loaded, or if they are out of date and need refreshing
            if (!_resources.ContainsKey(key) || SiteConfiguration.CheckSettingsNeedRefresh(_settingsType, localization))
            {
                LoadResourcesForLocalization(localization);
                if (!_resources.ContainsKey(key))
                {
                    Exception ex = new Exception(String.Format("No resources can be found for localization {0}. Check that the localization path is correct and the resources have been published.", localization.LocalizationId));
                    Log.Error(ex);
                    throw ex;
                }
            }
            return(_resources[key]);
        }
        /// <summary>
        /// Gets a semantic schema by id.
        /// </summary>
        /// <param name="id">The schema ID</param>
        /// <param name="loc">The localization</param>
        /// <returns>The semantic schema matching the id for the given module</returns>
        public static SemanticSchema GetSchema(string id, Localization loc)
        {
            string key = loc.LocalizationId;

            if (!_semanticMap.ContainsKey(key) || SiteConfiguration.CheckSettingsNeedRefresh(_mapSettingsType, loc))
            {
                LoadSemanticMapForLocalization(loc);
            }

            try
            {
                return(_semanticMap[key][id]);
            }
            catch (Exception)
            {
                throw new DxaException(
                          string.Format("Semantic schema {0} not defined in Localization [{1}]. Check that the Publish Settings page is published and the application cache is up to date.",
                                        id, loc)
                          );
            }
        }