/// <summary> /// Converts a content type to a jsonPayload object /// </summary> /// <param name="contentType"></param> /// <param name="isDeleted">if the item was deleted</param> /// <returns></returns> internal static JsonPayload FromContentType(IContentTypeBase contentType, bool isDeleted = false) { var contentTypeService = (ContentTypeService)ApplicationContext.Current.Services.ContentTypeService; var payload = new JsonPayload { Alias = contentType.Alias, Id = contentType.Id, PropertyTypeIds = contentType.PropertyTypes.Select(x => x.Id).ToArray(), //either IContentType or IMediaType or IMemberType Type = (contentType is IContentType) ? typeof(IContentType).Name : (contentType is IMediaType) ? typeof(IMediaType).Name : typeof(IMemberType).Name, DescendantPayloads = contentTypeService.GetDescendants(contentType).Select(x => FromContentType(x)).ToArray(), WasDeleted = isDeleted, PropertyRemoved = contentType.WasPropertyDirty("HasPropertyTypeBeenRemoved"), AliasChanged = contentType.WasPropertyDirty("Alias"), PropertyTypeAliasChanged = contentType.PropertyTypes.Any(x => x.WasPropertyDirty("Alias")), IsNew = contentType.WasPropertyDirty("HasIdentity") }; return(payload); }