Added to allow retreiving multiple items by id when you know the Ids, e.g.: using MNTP to select nodes and then needing to get them in Razor
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Dynamic;
|
|
using System.Collections;
|
|
using umbraco.cms.businesslogic.media;
|
|
|
|
namespace umbraco.MacroEngines
|
|
{
|
|
public class DynamicMediaList : DynamicObject, IEnumerable
|
|
{
|
|
public IEnumerable<DynamicMedia> Items { get; set; }
|
|
|
|
public DynamicMediaList()
|
|
{
|
|
Items = new List<DynamicMedia>();
|
|
}
|
|
public DynamicMediaList(IEnumerable<DynamicMedia> items)
|
|
{
|
|
List<DynamicMedia> list = items.ToList();
|
|
list.ForEach(node => node.ownerList = this);
|
|
Items = list;
|
|
}
|
|
public DynamicMediaList(IEnumerable<Media> items)
|
|
{
|
|
List<DynamicMedia> list = items.Select(x => new DynamicMedia(x)).ToList();
|
|
list.ForEach(node => node.ownerList = this);
|
|
Items = list;
|
|
}
|
|
|
|
public IEnumerator GetEnumerator()
|
|
{
|
|
return Items.GetEnumerator();
|
|
}
|
|
|
|
}
|
|
}
|