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:
agrath@gmail.com
2011-03-08 19:06:55 -13:00
parent 042e373b6a
commit fa5b85557f
@@ -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);
}
}
}
}