private PublishedContentType CreatePublishedContentType(PublishedItemType itemType, int id) { if (GetPublishedContentTypeById != null) { return(GetPublishedContentTypeById(id)); } IContentTypeComposition contentType; switch (itemType) { case PublishedItemType.Content: contentType = _contentTypeService.Get(id); break; case PublishedItemType.Media: contentType = _mediaTypeService.Get(id); break; case PublishedItemType.Member: contentType = _memberTypeService.Get(id); break; default: throw new ArgumentOutOfRangeException(nameof(itemType)); } if (contentType == null) { throw new Exception($"ContentTypeService failed to find a {itemType.ToString().ToLower()} type with id {id}."); } return(_publishedContentTypeFactory.CreateContentType(contentType)); }
private static PublishedContentType CreatePublishedContentType(PublishedItemType itemType, string alias) { if (GetPublishedContentTypeCallback != null) { return(GetPublishedContentTypeCallback(alias)); } IContentTypeComposition contentType; switch (itemType) { case PublishedItemType.Content: contentType = ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias); break; case PublishedItemType.Media: contentType = ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias); break; case PublishedItemType.Member: contentType = ApplicationContext.Current.Services.MemberTypeService.Get(alias); break; default: throw new ArgumentOutOfRangeException("itemType"); } if (contentType == null) { throw new InvalidOperationException(string.Format("ContentTypeService failed to find a {0} type with alias \"{1}\".", itemType.ToString().ToLower(), alias)); } return(new PublishedContentType(contentType)); }
public static PublishedContentType Get(PublishedItemType itemType, string alias) { var key = string.Format("PublishedContentType_{0}_{1}", itemType.ToString().ToLowerInvariant(), alias.ToLowerInvariant()); var type = ApplicationContext.Current.ApplicationCache.StaticCache.GetCacheItem <PublishedContentType>(key, () => CreatePublishedContentType(itemType, alias)); return(type); }
private IPublishedContentType CreatePublishedContentType(PublishedItemType itemType, Guid key) { IContentTypeComposition contentType = itemType switch { PublishedItemType.Content => _contentTypeService.Get(key), PublishedItemType.Media => _mediaTypeService.Get(key), PublishedItemType.Member => _memberTypeService.Get(key), _ => throw new ArgumentOutOfRangeException(nameof(itemType)), }; if (contentType == null) { throw new Exception($"ContentTypeService failed to find a {itemType.ToString().ToLower()} type with key \"{key}\"."); } return(_publishedContentTypeFactory.CreateContentType(contentType)); }
private static PublishedContentType CreatePublishedContentType(PublishedItemType itemType, string alias) { if (GetPublishedContentTypeCallback != null) { return(GetPublishedContentTypeCallback(alias)); } var contentType = itemType == PublishedItemType.Content ? (IContentTypeComposition)ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias) : (IContentTypeComposition)ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias); if (contentType == null) { throw new Exception(string.Format("ContentTypeService failed to find a {0} type with alias \"{1}\".", itemType.ToString().ToLower(), alias)); } return(new PublishedContentType(contentType)); }
private IPublishedContentType CreatePublishedContentType(PublishedItemType itemType, int id) { if (GetPublishedContentTypeById != null) { return(GetPublishedContentTypeById(id)); } IContentTypeComposition contentType = itemType switch { PublishedItemType.Content => _contentTypeService.Get(id), PublishedItemType.Media => _mediaTypeService.Get(id), PublishedItemType.Member => _memberTypeService.Get(id), _ => throw new ArgumentOutOfRangeException(nameof(itemType)), }; if (contentType == null) { throw new Exception($"ContentTypeService failed to find a {itemType.ToString().ToLower()} type with id {id}."); } return(_publishedContentTypeFactory.CreateContentType(contentType)); }
private static PublishedContentType CreatePublishedContentType(PublishedItemType itemType, string alias) { if (GetPublishedContentTypeCallback != null) return GetPublishedContentTypeCallback(alias); var contentType = itemType == PublishedItemType.Content ? (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetContentType(alias) : (IContentTypeComposition) ApplicationContext.Current.Services.ContentTypeService.GetMediaType(alias); if (contentType == null) throw new Exception(string.Format("ContentTypeService failed to find a {0} type with alias \"{1}\".", itemType.ToString().ToLower(), alias)); return new PublishedContentType(contentType); }