/// <summary> /// Generates single item filter for specified content location /// </summary> /// <returns>The single item filter.</returns> protected virtual ContentLocationSingleItemFilter CompileSingleItemFilterExpression(Type itemType) { if (!typeof(Content).IsAssignableFrom(itemType) && !typeof(DynamicContent).IsAssignableFrom(itemType)) { throw new ArgumentException("The type must be Content or Dynamic content"); } var selectedItemGuid = this.selectedItemsIds.Select(id => new Guid(id)).FirstOrDefault(); var items = this.GetItemsQuery(); IQueryable <string> itemIds = new List <string>().AsQueryable(); IQueryable <string> itemMasterIds = new List <string>().AsQueryable(); if (typeof(Content).IsAssignableFrom(itemType)) { var typedItems = items.OfType <Content>().Where(c => c.Id == selectedItemGuid || c.OriginalContentId == selectedItemGuid); itemIds = items.Select(n => n.Id.ToString()); itemMasterIds = typedItems.Where(i => i.OriginalContentId != Guid.Empty).Select(n => n.OriginalContentId.ToString()); } else { var typedItems = items.OfType <ILifecycleDataItemGeneric>().Where(c => c.Id == selectedItemGuid || c.OriginalContentId == selectedItemGuid); itemIds = items.Select(n => n.Id.ToString()); itemMasterIds = typedItems.Where(i => i.OriginalContentId != Guid.Empty).Select(n => n.OriginalContentId.ToString()); } var itemIdsList = itemIds.Distinct().ToList(); foreach (var item in itemMasterIds.Distinct()) { if (!itemIds.Contains(item)) { itemIdsList.Add(item); } } var filter = new ContentLocationSingleItemFilter(itemIdsList); return(filter); }
public static IEnumerable <IContentLocationInfo> GetLocations(Guid id, string providerName, Type mediaType) { var location = new ContentLocationInfo(); location.ContentType = mediaType; location.ProviderName = providerName; var mediaItem = LibrariesManager.GetManager(providerName).GetItem(mediaType, id) as MediaContent; var itemsList = new List <string>(); itemsList.Add(mediaItem.Id.ToString()); if (mediaItem.OriginalContentId != Guid.Empty) { itemsList.Add(mediaItem.OriginalContentId.ToString()); } var filter = new ContentLocationSingleItemFilter(itemsList); location.Filters.Add(filter); return(new[] { location }); }