Added support to DynamicNodeList for .Add and .Remove methods to support this use case:
http://our.umbraco.org/forum/developers/razor/17934-Creating-a-DynamicNodeList-with-a-'for'-loop
This commit is contained in:
@@ -14,7 +14,7 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
public class DynamicNodeList : DynamicObject, IEnumerable
|
||||
{
|
||||
public IEnumerable<DynamicNode> Items { get; set; }
|
||||
public List<DynamicNode> Items { get; set; }
|
||||
|
||||
public DynamicNodeList()
|
||||
{
|
||||
@@ -169,5 +169,19 @@ namespace umbraco.MacroEngines
|
||||
{
|
||||
return ((IQueryable<T>)Items.AsQueryable()).OrderBy(key);
|
||||
}
|
||||
|
||||
public void Add(DynamicNode node)
|
||||
{
|
||||
node.ownerList = this;
|
||||
this.Items.Add(node);
|
||||
}
|
||||
public void Remove(DynamicNode node)
|
||||
{
|
||||
if (this.Items.Contains(node))
|
||||
{
|
||||
node.ownerList = null;
|
||||
this.Items.Remove(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user