예제 #1
0
        public IPublishedContent Media(Guid id)
        {
            //TODO: This is horrible but until the media cache properly supports GUIDs we have no choice here and
            // currently there won't be any way to add this method correctly to `ITypedPublishedContentQuery` without breaking an interface and adding GUID support for media

            var entityService = Current.Services.EntityService; // fixme inject
            var mediaAttempt  = entityService.GetId(id, UmbracoObjectTypes.Media);

            return(mediaAttempt.Success ? ContentQuery.Media(mediaAttempt.Result) : null);
        }
예제 #2
0
        private IEnumerable <IPublishedContent> MediaForObjects(IEnumerable <object> ids)
        {
            var idsA = ids.ToArray();
            IEnumerable <int> intIds;

            if (ConvertIdsObjectToInts(idsA, out intIds))
            {
                return(ContentQuery.Media(intIds));
            }
            //IEnumerable<Guid> guidIds;
            //if (ConvertIdsObjectToGuids(idsA, out guidIds))
            //    return ContentQuery.Media(guidIds);
            return(Enumerable.Empty <IPublishedContent>());
        }
예제 #3
0
 private IPublishedContent MediaForObject(object id)
 {
     if (ConvertIdObjectToInt(id, out var intId))
     {
         return(ContentQuery.Media(intId));
     }
     if (ConvertIdObjectToGuid(id, out var guidId))
     {
         return(ContentQuery.Media(guidId));
     }
     if (ConvertIdObjectToUdi(id, out var udiId))
     {
         return(ContentQuery.Media(udiId));
     }
     return(null);
 }
예제 #4
0
 /// <summary>
 /// Gets the medias corresponding to the identifiers.
 /// </summary>
 /// <param name="ids">The media identifiers.</param>
 /// <returns>The existing medias corresponding to the identifiers.</returns>
 /// <remarks>If an identifier does not match an existing media, it will be missing in the returned value.</remarks>
 public IEnumerable <IPublishedContent> Media(IEnumerable <int> ids)
 {
     return(ContentQuery.Media(ids));
 }
예제 #5
0
 /// <summary>
 /// Gets the medias corresponding to the identifiers.
 /// </summary>
 /// <param name="ids">The media identifiers.</param>
 /// <returns>The existing medias corresponding to the identifiers.</returns>
 /// <remarks>If an identifier does not match an existing media, it will be missing in the returned value.</remarks>
 public IEnumerable <IPublishedContent> Media(params int[] ids)
 {
     return(ContentQuery.Media(ids));
 }
예제 #6
0
 public IPublishedContent Media(int id)
 {
     return(ContentQuery.Media(id));
 }