public DataTypeValidateFilter(IDataTypeService dataTypeService, PropertyEditorCollection propertyEditorCollection, IUmbracoMapper umbracoMapper) { _dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); _propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); }
public static void Configure(IUmbracoMapper umbracoMapper, IUmbracoHelperService umbracoHelperService) { UmbracoHelperService = umbracoHelperService; umbracoMapper.AddCustomMapping(typeof(BaseWebPage).FullName, MapBaseWebPage); umbracoMapper.AddCustomMapping(typeof(MediaFile).FullName, MapMediaFile); umbracoMapper.AddCustomMapping(typeof(IEnumerable<MediaFile>).FullName, MapMediaFiles); }
public StartPageViewModelFactory(IUmbracoMapper umbracoMapper, IUmbracoService umbracoService, IBlogPostService blogPostService, IUmbracoHelper umbracoHelper) : base(umbracoMapper, umbracoHelper) { _umbracoMapper = umbracoMapper; _umbracoService = umbracoService; _blogPostService = blogPostService; }
/// <summary> /// Maps the image model from the media node /// </summary> /// <param name="mapper">Umbraco mapper</param> /// <param name="media">Media node</param> /// <returns>Image model</returns> public static object GetImage(IUmbracoMapper mapper, IPublishedContent media) { var image = GetModel<ImageViewModel>(mapper, media); MapImageCrops(media, image); return image; }
//private readonly MembershipProvider membershipProvider; public ExtendedMemberController(PropertyEditorCollection propertyEditors, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ISqlContext sqlContext, ServiceContext services, AppCaches appCaches, IProfilingLogger logger, Umbraco.Core.IRuntimeState runtimeState, UmbracoHelper umbracoHelper, IMemberExtendedService memberExtendedService) : base(propertyEditors, globalSettings, umbracoContextAccessor, sqlContext, services, appCaches, logger, runtimeState, umbracoHelper) #endif { this.propertyEditors = propertyEditors; this.memberExtendedService = memberExtendedService; #if NET5_0_OR_GREATER this.dataTypeService = dataTypeService; this.memberTypeService = memberTypeService; this.memberGroupService = memberGroupService; this.memberManager = memberManager; this.umbracoMapper = umbracoMapper; this.backOfficeSecurityAccessor = backOfficeSecurityAccessor; settings = new Settings(configuration); #else dataTypeService = services.DataTypeService; memberTypeService = services.MemberTypeService; memberGroupService = services.MemberGroupService; //membershipProvider = MembershipProviderExtensions.GetMembersMembershipProvider(); settings = new Settings(); #endif }
/// <summary> /// Native mapper for mapping a multiple media picker property /// </summary> /// <param name="mapper">The mapper</param> /// <param name="contentToMapFrom">Umbraco content item to map from</param> /// <param name="propName">Name of the property to map</param> /// <param name="isRecursive">Flag to indicate if property should be retrieved recursively up the tree</param> /// <returns>MediaFile instance</returns> public static object MapMediaFileCollection(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { // If Umbraco Core Property Editor Converters will get IEnumerable<IPublishedContent>, so try that first var mediaCollection = GetTypedMediaFromPropertyValue <IEnumerable <IPublishedContent> >(contentToMapFrom, propName, isRecursive); if (mediaCollection == null) { // Also check for single IPublishedContent (which could get if multiple media disabled) var media = contentToMapFrom.GetPropertyValue <IPublishedContent>(propName, isRecursive, null); if (media != null) { mediaCollection = new List <IPublishedContent> { media }; } if (mediaCollection == null) { // If Umbraco Core Property Editor Converters not installed, need to dig out the Ids var mediaIds = contentToMapFrom.GetPropertyValue <string>(propName, isRecursive, string.Empty); if (!string.IsNullOrEmpty(mediaIds)) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); mediaCollection = new List <IPublishedContent>(); foreach (var mediaId in mediaIds.Split(',')) { ((List <IPublishedContent>)mediaCollection).Add(umbracoHelper.TypedMedia(mediaId)); } } } } return(mediaCollection != null?GetMediaFileCollection(mediaCollection, mapper.AssetsRootUrl) : null); }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <IMacro, EntityBasic>((source, context) => new EntityBasic(), Map); mapper.Define <IMacro, MacroDisplay>((source, context) => new MacroDisplay(), Map); mapper.Define <IMacro, IEnumerable <MacroParameter> >((source, context) => context.MapEnumerable <IMacroProperty, MacroParameter>(source.Properties.Values)); mapper.Define <IMacroProperty, MacroParameter>((source, context) => new MacroParameter(), Map); }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <IUser, BackOfficeIdentityUser>( (source, context) => { var target = new BackOfficeIdentityUser(_globalSettings, source.Id, source.Groups); target.DisableChangeTracking(); return(target); }, (source, target, context) => { Map(source, target); target.ResetDirtyProperties(true); target.EnableChangeTracking(); }); mapper.Define <IMember, MemberIdentityUser>( (source, context) => { var target = new MemberIdentityUser(source.Id); target.DisableChangeTracking(); return(target); }, (source, target, context) => { Map(source, target); target.ResetDirtyProperties(true); target.EnableChangeTracking(); }); }
public DataTypeController( PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot <ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer) { _propertyEditors = propertyEditors ?? throw new ArgumentNullException(nameof(propertyEditors)); _dataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); _propertyEditorCollection = propertyEditorCollection ?? throw new ArgumentNullException(nameof(propertyEditorCollection)); _contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService)); _mediaTypeService = mediaTypeService ?? throw new ArgumentNullException(nameof(mediaTypeService)); _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); _backOfficeSecurityAccessor = backOfficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
public LectureController(IUmbracoMapper mapper, ISubscriptionsService subscriptions, ILecturesService lectures, ICoursesContentService coursesContentService) { _mapper = mapper; _subscriptions = subscriptions; _lectures = lectures; _coursesContentService = coursesContentService; }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <ILanguage, EntityBasic>((source, context) => new EntityBasic(), Map); mapper.Define <ILanguage, ContentEditing.Language>((source, context) => new ContentEditing.Language(), Map); mapper.Define <IEnumerable <ILanguage>, IEnumerable <ContentEditing.Language> >( (source, context) => new List <ContentEditing.Language>(), Map); }
/// <summary> /// Gets model of given type when mapping from dictionary and selected content /// </summary> /// <typeparam name="T">The type</typeparam> /// <param name="mapper">Umbraco mapper</param> /// <param name="dictionary">Dictionary</param> /// <param name="contentAlias">The alias of the property containing the content to map from</param> /// <returns>The model</returns> private static T GetModel <T>(IUmbracoMapper mapper, Dictionary <string, object> dictionary, string contentAlias = "content") where T : BaseModuleViewModel, new() { try { var result = new T(); mapper.Map(dictionary, result); var contentToMapFrom = dictionary.ContainsKey(contentAlias) ? dictionary[contentAlias] as IEnumerable <IPublishedContent> : null; if (contentToMapFrom == null) { return(result); } var contentResult = new T(); mapper.Map(contentToMapFrom.SingleOrDefault(), contentResult); result = CopyValues(result, contentResult); return(result); } catch (Exception ex) { LogHelper.Error <ArchetypeMapper>(string.Format("Error getting data for model: {0}", ex.InnerException), ex); } return(null); }
public static object GetUser(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { var userId = contentToMapFrom.GetPropertyValue <int>(propertyAlias, recursive); var userService = ApplicationContext.Current.Services.UserService; return(userService.GetUserById(userId)); }
public TemplateController( IFileService fileService, IUmbracoMapper umbracoMapper, IShortStringHelper shortStringHelper) : this(fileService, umbracoMapper, shortStringHelper, StaticServiceProvider.Instance.GetRequiredService <IDefaultViewContentProvider>()) { }
public DataTypeController( PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IOptionsSnapshot <ContentSettings> contentSettings, IUmbracoMapper umbracoMapper, PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IConfigurationEditorJsonSerializer serializer) : this( propertyEditors, dataTypeService, contentSettings, umbracoMapper, propertyEditorCollection, contentTypeService, mediaTypeService, memberTypeService, localizedTextService, backOfficeSecurityAccessor, serializer, StaticServiceProvider.Instance.GetRequiredService <IDataTypeUsageService>()) { }
private T GetInstance <T>(object fromObject, IUmbracoMapper mapper) where T : class { T instance = default(T); if (fromObject != null) { // Check first if already IPublishedContent (as core converters installed) var content = fromObject as IPublishedContent; if (content == null) { // Otherwise handle if Id passed int id; if (int.TryParse(fromObject.ToString(), out id)) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); content = umbracoHelper.TypedContent(id); } } if (content != null) { instance = Activator.CreateInstance <T>(); mapper.Map(content, instance); } } return(instance); }
/// <summary> /// Initializes a new instance of the <see cref="MemberController"/> class. /// </summary> /// <param name="cultureDictionary">The culture dictionary</param> /// <param name="loggerFactory">The logger factory</param> /// <param name="shortStringHelper">The string helper</param> /// <param name="eventMessages">The event messages factory</param> /// <param name="localizedTextService">The entry point for localizing key services</param> /// <param name="propertyEditors">The property editors</param> /// <param name="umbracoMapper">The mapper</param> /// <param name="memberService">The member service</param> /// <param name="memberTypeService">The member type service</param> /// <param name="memberManager">The member manager</param> /// <param name="dataTypeService">The data-type service</param> /// <param name="backOfficeSecurityAccessor">The back office security accessor</param> /// <param name="jsonSerializer">The JSON serializer</param> /// <param name="passwordChanger">The password changer</param> public MemberController( ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, PropertyEditorCollection propertyEditors, IUmbracoMapper umbracoMapper, IMemberService memberService, IMemberTypeService memberTypeService, IMemberManager memberManager, IDataTypeService dataTypeService, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IJsonSerializer jsonSerializer, IPasswordChanger <MemberIdentityUser> passwordChanger, ICoreScopeProvider scopeProvider) : base(cultureDictionary, loggerFactory, shortStringHelper, eventMessages, localizedTextService, jsonSerializer) { _propertyEditors = propertyEditors; _umbracoMapper = umbracoMapper; _memberService = memberService; _memberTypeService = memberTypeService; _memberManager = memberManager; _dataTypeService = dataTypeService; _localizedTextService = localizedTextService; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _jsonSerializer = jsonSerializer; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; _scopeProvider = scopeProvider; }
public MemberTypeController( ICultureDictionary cultureDictionary, EditorValidatorCollection editorValidatorCollection, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, IMemberTypeService memberTypeService, IUmbracoMapper umbracoMapper, ILocalizedTextService localizedTextService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IShortStringHelper shortStringHelper) : base(cultureDictionary, editorValidatorCollection, contentTypeService, mediaTypeService, memberTypeService, umbracoMapper, localizedTextService) { _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); _shortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <IContent, ContentPropertyCollectionDto>((source, context) => new ContentPropertyCollectionDto(), Map); mapper.Define <IContent, ContentItemDisplay>((source, context) => new ContentItemDisplay(), Map); mapper.Define <IContent, ContentVariantDisplay>((source, context) => new ContentVariantDisplay(), Map); mapper.Define <IContent, ContentItemBasic <ContentPropertyBasic> >((source, context) => new ContentItemBasic <ContentPropertyBasic>(), Map); }
/// <summary> /// Defines a custom mapping to a complex type on a view model of type <see cref="MediaFile"/> /// </summary> /// <param name="mapper">Instance of <see cref="UmbracoMapper"/></param> /// <param name="contentToMapFrom">Instance of <see cref="IPublishedContent"/> to map from</param> /// <param name="propertyAlias">Property alias</param> /// <param name="recursive">Flag for mapping recursively</param> /// <returns>Mapped instance of <see cref="MediaFile"/> </returns> public static object Map(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { var value = contentToMapFrom.GetProperty(propertyAlias, recursive).DataValue; if (value == null) { return(null); } int id; if (!int.TryParse(value.ToString(), out id) || id <= 0) { return(null); } var umbraco = new UmbracoHelper(UmbracoContext.Current); var media = umbraco.TypedMedia(id); var model = new MediaFile(); mapper.Map(media, model); return(model); }
public CurrentUserController( MediaFileManager mediaFileManager, IOptionsSnapshot <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger, IUserDataService userDataService) { _mediaFileManager = mediaFileManager; _contentSettings = contentSettings.Value; _hostingEnvironment = hostingEnvironment; _imageUrlGenerator = imageUrlGenerator; _backofficeSecurityAccessor = backofficeSecurityAccessor; _userService = userService; _umbracoMapper = umbracoMapper; _backOfficeUserManager = backOfficeUserManager; _localizedTextService = localizedTextService; _appCaches = appCaches; _shortStringHelper = shortStringHelper; _passwordChanger = passwordChanger; _userDataService = userDataService; }
public MemberTypeQueryController( IMemberTypeService memberTypeService, IUmbracoMapper umbracoMapper) { _memberTypeService = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); }
internal static void BindModel(ContentItemSave model, IContent persistedContent, ContentModelBinderHelper modelBinderHelper, IUmbracoMapper umbracoMapper) { model.PersistedContent = persistedContent; //create the dto from the persisted model if (model.PersistedContent != null) { foreach (ContentVariantSave variant in model.Variants) { //map the property dto collection with the culture of the current variant variant.PropertyCollectionDto = umbracoMapper.Map <ContentPropertyCollectionDto>( model.PersistedContent, context => { // either of these may be null and that is ok, if it's invariant they will be null which is what is expected context.SetCulture(variant.Culture); context.SetSegment(variant.Segment); }); //now map all of the saved values to the dto modelBinderHelper.MapPropertyValuesFromSaved(variant, variant.PropertyCollectionDto); } } }
public CurrentUserController( MediaFileManager mediaFileManager, IOptions <ContentSettings> contentSettings, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUserService userService, IUmbracoMapper umbracoMapper, IBackOfficeUserManager backOfficeUserManager, ILoggerFactory loggerFactory, ILocalizedTextService localizedTextService, AppCaches appCaches, IShortStringHelper shortStringHelper, IPasswordChanger <BackOfficeIdentityUser> passwordChanger) : this( mediaFileManager, StaticServiceProvider.Instance.GetRequiredService <IOptionsSnapshot <ContentSettings> >(), hostingEnvironment, imageUrlGenerator, backofficeSecurityAccessor, userService, umbracoMapper, backOfficeUserManager, localizedTextService, appCaches, shortStringHelper, passwordChanger, StaticServiceProvider.Instance.GetRequiredService <IUserDataService>()) { }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <UserGroupSave, IUserGroup>( (source, context) => new UserGroup(_shortStringHelper) { CreateDate = DateTime.UtcNow }, Map); mapper.Define <UserInvite, IUser>(Map); mapper.Define <IProfile, UserProfile>((source, context) => new UserProfile(), Map); mapper.Define <IReadOnlyUserGroup, UserGroupBasic>((source, context) => new UserGroupBasic(), Map); mapper.Define <IUserGroup, UserGroupBasic>((source, context) => new UserGroupBasic(), Map); mapper.Define <IUserGroup, AssignedUserGroupPermissions>( (source, context) => new AssignedUserGroupPermissions(), Map); mapper.Define <EntitySlim, AssignedContentPermissions>( (source, context) => new AssignedContentPermissions(), Map); mapper.Define <IUserGroup, UserGroupDisplay>((source, context) => new UserGroupDisplay(), Map); mapper.Define <IUser, UserBasic>((source, context) => new UserBasic(), Map); mapper.Define <IUser, UserDetail>((source, context) => new UserDetail(), Map); // used for merging existing UserSave to an existing IUser instance - this will not create an IUser instance! mapper.Define <UserSave, IUser>(Map); // important! Currently we are never mapping to multiple UserDisplay objects but if we start doing that // this will cause an N+1 and we'll need to change how this works. mapper.Define <IUser, UserDisplay>((source, context) => new UserDisplay(), Map); }
// Umbraco ignores routes that end with something that looks like a file extension. // Such as the '.com' domain extensions of emails used in the validate page // That's why we need to manually force the creation of UmbracoContext public AccountController(IMembershipService membership, IEmailService email, IUmbracoMapper mapper, IUserService user) : base(UmbracoContextExtensions.GetOrCreateContext()) { _membership = membership; _email = email; _mapper = mapper; _user = user; }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <PropertyGroup, Tab <ContentPropertyDisplay> >((source, context) => new Tab <ContentPropertyDisplay>(), Map); mapper.Define <IProperty, ContentPropertyBasic>((source, context) => new ContentPropertyBasic(), Map); mapper.Define <IProperty, ContentPropertyDto>((source, context) => new ContentPropertyDto(), Map); mapper.Define <IProperty, ContentPropertyDisplay>((source, context) => new ContentPropertyDisplay(), Map); }
public void DefineMaps(IUmbracoMapper mapper) { mapper.Define <IMember, MemberDisplay>((source, context) => new MemberDisplay(), Map); mapper.Define <IMember, MemberBasic>((source, context) => new MemberBasic(), Map); mapper.Define <IMemberGroup, MemberGroupDisplay>((source, context) => new MemberGroupDisplay(), Map); mapper.Define <UmbracoIdentityRole, MemberGroupDisplay>((source, context) => new MemberGroupDisplay(), Map); mapper.Define <IMember, ContentPropertyCollectionDto>((source, context) => new ContentPropertyCollectionDto(), Map); }
public FeedbackController(IFeedbackService feedbackService, ICoursesContentService coursesContentService, IUmbracoMapper mapper, IUserService userService, ISubscriptionsService subscriptionsService) { _feedbackService = feedbackService; _coursesContentService = coursesContentService; _mapper = mapper; _userService = userService; _subscriptionsService = subscriptionsService; }
public LanguageController(ILocalizationService localizationService, IUmbracoMapper umbracoMapper, IOptions <GlobalSettings> globalSettings) { _localizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService)); _umbracoMapper = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper)); _globalSettings = globalSettings.Value ?? throw new ArgumentNullException(nameof(globalSettings)); }
/// <summary> /// Maps the image model from the media node /// </summary> /// <param name="mapper">Umbraco mapper</param> /// <param name="media">Media node</param> /// <returns>Image model</returns> public static object GetImage(IUmbracoMapper mapper, IPublishedContent media) { var image = GetModel <ImageViewModel>(mapper, media); MapImageCrops(media, image); return(image); }
public CourseController(ICoursesService courses, IUmbracoMapper mapper, ISubscriptionsService subscriptions, ILecturesService lectures, IAssessmentsService assessmentsService) { _courses = courses; _mapper = mapper; _subscriptions = subscriptions; _lectures = lectures; _assessmentsService = assessmentsService; }
public static object GetGrid(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { var grid = contentToMapFrom.GetPropertyValue<Grid>(propertyAlias, recursive); foreach (var control in grid.Sections.SelectMany(s => s.Rows.SelectMany(r => r.Areas.SelectMany(a => a.Controls))).Where(control => control.Value != null)) { control.TypedValue = GetTypedVaue(control.Editor.Alias, control.Value); } return grid; }
private static MediaFile GetMediaFile(IUmbracoMapper mapper, IPublishedContent publishedMediaItem) { if (publishedMediaItem == null) { return null; } var mediaFile = new MediaFile(); mapper.Map(publishedMediaItem, mediaFile); return mediaFile; }
public static object GetImageFromValue(IUmbracoMapper mapper, object value) { if (value == null || string.IsNullOrEmpty(value.ToString())) { return null; } var media = new UmbracoHelper(UmbracoContext.Current).TypedMedia(value.ToString()); var image = GetModel<ImageViewModel>(mapper, media); MapImageCrops(media, image); return image; }
/// <summary> /// Native mapper for mapping a media picker property /// </summary> /// <param name="mapper">The mapper</param> /// <param name="contentToMapFrom">Umbraco content item to map from</param> /// <param name="propName">Name of the property to map</param> /// <param name="isRecursive">Flag to indicate if property should be retrieved recursively up the tree</param> /// <returns>MediaFile instance</returns> public static object MapMediaFile(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { // If Umbraco Core Property Editor Converters will get IPublishedContent, so try that first var media = contentToMapFrom.GetPropertyValue<IPublishedContent>(propName, isRecursive, null); if (media == null) { // If Umbraco Core Property Editor Converters not installed, need to dig out the Id var mediaId = contentToMapFrom.GetPropertyValue<string>(propName, isRecursive, string.Empty); if (!string.IsNullOrEmpty(mediaId)) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); media = umbracoHelper.TypedMedia(mediaId); } } if (media != null) { return GetMediaFile(media, mapper.AssetsRootUrl); } return null; }
/// <summary> /// Native mapper for mapping a multiple media picker property /// </summary> /// <param name="mapper">The mapper</param> /// <param name="contentToMapFrom">Umbraco content item to map from</param> /// <param name="propName">Name of the property to map</param> /// <param name="isRecursive">Flag to indicate if property should be retrieved recursively up the tree</param> /// <returns>MediaFile instance</returns> public static object MapMediaFileCollection(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { // If Umbraco Core Property Editor Converters will get IEnumerable<IPublishedContent>, so try that first var mediaCollection = contentToMapFrom.GetPropertyValue<IEnumerable<IPublishedContent>>(propName, isRecursive, null); if (mediaCollection == null) { // Also check for single IPublishedContent (which could get if multiple media disabled) var media = contentToMapFrom.GetPropertyValue<IPublishedContent>(propName, isRecursive, null); if (media != null) { mediaCollection = new List<IPublishedContent> { media }; } if (mediaCollection == null) { // If Umbraco Core Property Editor Converters not installed, need to dig out the Ids var mediaIds = contentToMapFrom.GetPropertyValue<string>(propName, isRecursive, string.Empty); if (!string.IsNullOrEmpty(mediaIds)) { var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); mediaCollection = new List<IPublishedContent>(); foreach (var mediaId in mediaIds.Split(',')) { ((List<IPublishedContent>)mediaCollection).Add(umbracoHelper.TypedMedia(mediaId)); } } } } if (mediaCollection != null) { return GetMediaFileCollection(mediaCollection, mapper.AssetsRootUrl); } return null; }
private static object MapMediaFiles(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyName, bool recursive) { var mediaFiles = new List<MediaFile>(); foreach (var stringId in contentToMapFrom.GetPropertyValue<string>(propertyName).Split(',')) { int id; if (!int.TryParse(stringId, out id)) { continue; } IPublishedContent publishedMediaItem = UmbracoHelperService.TypedMedia(id); MediaFile mediaFile = GetMediaFile(mapper, publishedMediaItem); if (mediaFile != null) { mediaFiles.Add(mediaFile); } } return mediaFiles; }
public static object GetLinksFromValue(IUmbracoMapper mapper, object value) { return value == null ? null : new MultiUrls(value.ToString()); }
public static object GetLinks(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { return contentToMapFrom.GetPropertyValue<MultiUrls>(propertyAlias, recursive); }
public static object GetLink(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { var links = contentToMapFrom.GetPropertyValue<MultiUrls>(propertyAlias, recursive); return links != null ? links.SingleOrDefault() : null; }
private static object MapGeoCoordinateFromObject(IUmbracoMapper mapper, object value) { return GetGeoCoordinate(value.ToString()); }
public static object GetGoogleMap(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { return contentToMapFrom.GetPropertyValue<GoogleMap>(propertyAlias, recursive); }
public ContactPageHandler(IUmbracoMapper mapper, IMetadataHandler metadataHandler, INavigationHandler navigationHandler) : base(mapper, metadataHandler, navigationHandler) { }
public ArticleController(IUmbracoMapper mapper) : base(mapper) { }
public MetadataHandler(IUmbracoMapper mapper) : base(mapper) { }
public RegistrationPageHandler(IUmbracoMapper mapper, IMetadataHandler metadataHandler, INavigationHandler navigationHandler) : base(mapper, metadataHandler, navigationHandler) { }
public NavigationHandler(IUmbracoMapper mapper, IRootContentLocator rootContentLocator) : base(mapper) { _rootContentLocator = rootContentLocator; }
public ErrorHandler(IUmbracoMapper mapper, IMetadataHandler metadataHandler) : base(mapper) { _metadataHandler = metadataHandler; }
private static object MapGeoCoordinateForCollection(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { return GetGeoCoordinate(contentToMapFrom.GetPropertyValue("geoCoordinate", false).ToString()); }
public CurrentPageMapperFactory() { _umbracoMapper = new UmbracoMapper(); }
private static object MapGeoCoordinateForCollectionFromObject(IUmbracoMapper mapper, object value) { return GetGeoCoordinate(((IPublishedContent)value).GetPropertyValue("geoCoordinate", false).ToString()); }
/// <summary> /// Maps the image model by property alias /// </summary> /// <param name="mapper">Umbraco mapper</param> /// <param name="contentToMapFrom">Content to map from</param> /// <param name="propertyAlias">Property alias</param> /// <param name="recursive">Recursive</param> /// <returns>Image model</returns> public static object GetImage(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyAlias, bool recursive) { var media = contentToMapFrom.GetPropertyValue<IPublishedContent>(propertyAlias, recursive); return GetImage(mapper, media); }
/// <summary> /// Native mapper for mapping a DAMP property /// </summary> /// <param name="mapper">The mapper</param> /// <param name="contentToMapFrom">Umbraco content item to map from</param> /// <param name="propName">Name of the property to map</param> /// <param name="isRecursive">Flag to indicate if property should be retrieved recursively up the tree</param> /// <returns>MediaFile instance</returns> public static object MapMediaFile(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propName, bool isRecursive) { return GetMediaFile(contentToMapFrom.GetPropertyValue<DampModel>(propName, isRecursive, null), mapper.AssetsRootUrl); }
public HomeController(IUmbracoMapper mapper) : base(mapper) { }
public UberDocTypeController(IUmbracoMapper mapper) : base(mapper) { }
public NewsLandingPageController(IUmbracoMapper mapper) : base(mapper) { }
private static object MapMediaFile(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyName, bool recursive) { IPublishedContent publishedMediaItem = UmbracoHelperService.TypedMedia(contentToMapFrom.GetPropertyValue<int>(propertyName)); return GetMediaFile(mapper, publishedMediaItem); }
protected BaseHandler(IUmbracoMapper mapper) { Mapper = mapper; }
private static object MapBaseWebPage(IUmbracoMapper mapper, IPublishedContent contentToMapFrom, string propertyName, bool recursive) { var obj = new BaseWebPage(); mapper.Map(UmbracoHelperService.TypedContent(contentToMapFrom.GetPropertyValue<int>(propertyName)), obj); return obj; }