private static string GetPrefix(List <SemanticVocabulary> vocabularies, string vocab) { SemanticVocabulary vocabulary = vocabularies.Find(v => v.Vocab.Equals(vocab)); if (vocabulary != null) { return(vocabulary.Prefix); } Log.Warn("Prefix not found for semantic vocabulary '{0}'", vocab); return(null); }
/// <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) { SemanticVocabulary semanticVocabulary = loc.GetSemanticVocabularies().FirstOrDefault(sv => sv.Vocab == vocab); if (semanticVocabulary == null) { throw new DxaException( string.Format("No vocabulary defined for '{0}' in Localization [{1}]. {2}", vocab, loc, Constants.CheckSettingsUpToDate) ); } return(semanticVocabulary.Prefix); }
/// <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, ILocalization loc) { SemanticVocabulary semanticVocabulary = loc.GetSemanticVocabularies().FirstOrDefault(sv => sv.Vocab == vocab); if (semanticVocabulary == null) { throw new DxaException( $"No vocabulary defined for '{vocab}' in Localization [{loc}]. {Constants.CheckSettingsUpToDate}" ); } return(semanticVocabulary.Prefix); }
private static string GetVocabulary(List <SemanticVocabulary> vocabularies, string prefix) { SemanticVocabulary vocabulary = vocabularies.Find(v => v.Prefix.Equals(prefix)); if (vocabulary != null) { return(vocabulary.Vocab); } Exception ex = new Exception(string.Format("Semantic vocabulary not found for prefix '{0}'", prefix)); Log.Error(ex); // TODO should we throw the exception here or return the default vocabulary? throw ex; }