/// <summary> /// Adds the mapper configuration to the mapping registry /// </summary> /// <param name="config">The mapper configuration</param> public static void AddMapper(IUmbMapperConfig config) { if (Mappers.ContainsKey(config.MappedType)) { return; } config.Init(); Mappers.TryAdd(config.MappedType, config); }
/// <inheritdoc/> public IPublishedContent CreateModel(IPublishedContent content) { UmbracoContext context = UmbracoContext.Current; if (context != null && context.IsFrontEndUmbracoRequest) { string typeName = this.ResolveTypeName(content); IUmbMapperConfig mapper = this.registeredMappers.FirstOrDefault(m => m.MappedType.Name.InvariantEquals(typeName)); if (mapper != null) { return((IPublishedContent)content.MapTo(mapper.MappedType)); } } return(content); }