/// <summary> /// Gets Semantic Schema for a given schema identifier. /// </summary> /// <param name="schemaId">The schema identifier.</param> /// <returns>The Semantic Schema configuration.</returns> public virtual SemanticSchema GetSemanticSchema(string schemaId) { if (schemaId == null) { throw new DxaException("Schema Id must not be null."); } // This method is called a lot, so intentionally no Tracer here. if (_semanticSchemas == null) { _localization.LoadStaticContentItem("mappings/schemas.json", ref _semanticSchemas); _semanticSchemaMap = _semanticSchemas.ToDictionary(ss => ss.Id.ToString(CultureInfo.InvariantCulture)); foreach (SemanticSchema semanticSchema in _semanticSchemas) { semanticSchema.Initialize(_localization); } } SemanticSchema result; if (!_semanticSchemaMap.TryGetValue(schemaId, out result)) { throw new DxaException( $"Semantic schema '{schemaId}' not defined in Localization [{this}]. {Constants.CheckSettingsUpToDate}" ); } return(result); }
protected void LoadResources() { using (new Tracer(this)) { try { BootstrapData resourcesData = null; _localization.LoadStaticContentItem("resources/_all.json", ref resourcesData); var newResources = new Hashtable(); foreach (string staticContentItemUrl in resourcesData.Files) { string type = staticContentItemUrl.Substring( staticContentItemUrl.LastIndexOf("/", StringComparison.Ordinal) + 1); type = type.Substring(0, type.LastIndexOf(".", StringComparison.Ordinal)).ToLower(); string resourcesJson = SiteConfiguration.ContentProvider.GetStaticContentItem(staticContentItemUrl, _localization) .GetText(); IDictionary <string, object> resources = JsonConvert.DeserializeObject <Dictionary <string, object> >(resourcesJson); foreach (KeyValuePair <string, object> resource in resources) { //we ensure resource key uniqueness by adding the type (which comes from the filename) newResources.Add($"{type}.{resource.Key}", resource.Value); } } _resources = newResources; } catch (Exception) { Log.Warn("Failed to open 'resources/_all.json'"); _resources = new Dictionary <string, object>(); } } }