2016-11-16 21:45:01 +03:00
|
|
|
|
public <#NodeName#> Add(<#ListElementType#> elem, SourceContext sc = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>.Add(elem);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
if (elem != null)
|
|
|
|
|
|
elem.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
if (sc != null)
|
|
|
|
|
|
source_context = sc;
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddFirst(<#ListElementType#> el)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>.Insert(0, el);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
FillParentsInDirectChilds();
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddFirst(IEnumerable<<#ListElementType#>> els)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>.InsertRange(0, els);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
foreach (var el in els)
|
|
|
|
|
|
if (el != null)
|
|
|
|
|
|
el.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AddMany(params <#ListElementType#>[] els)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>.AddRange(els);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
foreach (var el in els)
|
|
|
|
|
|
if (el != null)
|
|
|
|
|
|
el.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int FindIndexInList(<#ListElementType#> el)
|
|
|
|
|
|
{
|
|
|
|
|
|
var ind = <#ListName#>.FindIndex(x => x == el);
|
|
|
|
|
|
if (ind == -1)
|
|
|
|
|
|
throw new Exception(string.Format("У списка {0} не найден элемент {1} среди дочерних\n", this, el));
|
|
|
|
|
|
return ind;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InsertAfter(<#ListElementType#> el, <#ListElementType#> newel)
|
|
|
|
|
|
{
|
2017-02-12 22:01:44 +03:00
|
|
|
|
<#ListName#>.Insert(FindIndexInList(el) + 1, newel);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InsertAfter(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
|
|
|
|
|
|
{
|
2017-02-12 22:01:44 +03:00
|
|
|
|
<#ListName#>.InsertRange(FindIndexInList(el) + 1, newels);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
foreach (var newel in newels)
|
2017-06-01 23:49:15 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InsertBefore(<#ListElementType#> el, <#ListElementType#> newel)
|
|
|
|
|
|
{
|
2017-02-12 22:01:44 +03:00
|
|
|
|
<#ListName#>.Insert(FindIndexInList(el), newel);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InsertBefore(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
|
|
|
|
|
|
{
|
2017-02-12 22:01:44 +03:00
|
|
|
|
<#ListName#>.InsertRange(FindIndexInList(el), newels);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
foreach (var newel in newels)
|
2017-06-01 23:49:15 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Remove(<#ListElementType#> el)
|
|
|
|
|
|
{
|
|
|
|
|
|
return <#ListName#>.Remove(el);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ReplaceInList(<#ListElementType#> el, <#ListElementType#> newel)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>[FindIndexInList(el)] = newel;
|
2017-05-20 13:54:40 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ReplaceInList(<#ListElementType#> el, IEnumerable<<#ListElementType#>> newels)
|
|
|
|
|
|
{
|
|
|
|
|
|
var ind = FindIndexInList(el);
|
|
|
|
|
|
<#ListName#>.RemoveAt(ind);
|
|
|
|
|
|
<#ListName#>.InsertRange(ind, newels);
|
2017-05-20 13:54:40 +03:00
|
|
|
|
foreach (var newel in newels)
|
2017-06-01 23:49:15 +03:00
|
|
|
|
if (newel != null)
|
|
|
|
|
|
newel.Parent = this;
|
2016-11-16 21:45:01 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int RemoveAll(Predicate<<#ListElementType#>> match)
|
|
|
|
|
|
{
|
|
|
|
|
|
return <#ListName#>.RemoveAll(match);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public <#ListElementType#> Last()
|
|
|
|
|
|
{
|
|
|
|
|
|
return <#ListName#>[<#ListName#>.Count - 1];
|
|
|
|
|
|
}
|
2017-06-01 21:54:52 +03:00
|
|
|
|
|
|
|
|
|
|
public int Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return <#ListName#>.Count; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Insert(int pos, <#ListElementType#> el)
|
|
|
|
|
|
{
|
|
|
|
|
|
<#ListName#>.Insert(pos,el);
|
|
|
|
|
|
if (el != null)
|
|
|
|
|
|
el.Parent = this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|