Class BaseHasChildren<T>
A base class that items can inherit from that implements the IHasChildren<T> functionality
Inheritance
Inherited Members
Namespace: LemonEdge.Utils
Assembly: LemonEdge.Utils.dll
Syntax
[DataContract(IsReference = true)]
public abstract class BaseHasChildren<T> : IHasChildren<T>, IHasChildren where T : BaseHasChildren<T>
Type Parameters
Name | Description |
---|---|
T | The type that all Child items are of, and this item itself is. The type must implement BaseHasChildren<T> |
Constructors
BaseHasChildren()
Creates a new BaseHasChildren
Declaration
public BaseHasChildren()
BaseHasChildren(Func<T, int>)
Creates a new BaseHasChildren with a function that specifies certain ordering to be used for all the Child Items
Declaration
public BaseHasChildren(Func<T, int> getOrder)
Parameters
Type | Name | Description |
---|---|---|
Func<T, int> | getOrder | A function that given a child item returns the order it should be enumerated in when enumerating Children |
BaseHasChildren(Func<T, int>, T)
Creates a new BaseHasChildren with a function that specifies certain ordering to be used for all the Child Items, and which item is the parent of this item itself
Declaration
protected BaseHasChildren(Func<T, int> getOrder, T parent)
Parameters
Type | Name | Description |
---|---|---|
Func<T, int> | getOrder | A function that given a child item returns the order it should be enumerated in when enumerating Children |
T | parent | The BasHasChildren item that is the parent item of this one, and this contains it in its Children collection |
BaseHasChildren(T)
Creates a new BaseHasChildren item with the specified BaseHasChildren item as its Parent item
Declaration
protected BaseHasChildren(T parent)
Parameters
Type | Name | Description |
---|---|---|
T | parent | The BasHasChildren item that is the parent item of this one, and this contains it in its Children collection |
Properties
Children
All Child items in this item. If this has a Order, then this is enumerated according to that order
Declaration
public virtual IEnumerable<T> Children { get; }
Property Value
Type | Description |
---|---|
IEnumerable<T> |
Order
A function that returns the order a given child item should appear in when enumerating the Children collection
Declaration
protected Func<T, int> Order { get; }
Property Value
Type | Description |
---|---|
Func<T, int> |
Parent
Holds a link to the parent item (if there is one) that this item is a child of
Declaration
public T Parent { get; }
Property Value
Type | Description |
---|---|
T |
Methods
AddChild(IHasChildren)
Adds a child item to the collection of Children in this item
Declaration
public void AddChild(IHasChildren item)
Parameters
Type | Name | Description |
---|---|---|
IHasChildren | item | The item to add to this items Children. It can not already have another Parent, and this method will set its Parent to this item itself |
AddChild(T, bool)
Adds a child item to the collection of Children in this item
Declaration
public void AddChild(T item, bool allowDuplicate = false)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add to this items Children. It can not already have another Parent, and this method will set its Parent to this item itself |
bool | allowDuplicate |
Exceptions
Type | Condition |
---|---|
ArgumentException | If the item to be added already has another Parent an exception is thrown |
ClearChildren()
Clears all children contained within this item
Declaration
public void ClearChildren()
ClearMyParent()
Declaration
protected void ClearMyParent()
DeleteChild(IHasChildren)
Removes a child item from the collection of Children in this item
Declaration
public void DeleteChild(IHasChildren item)
Parameters
Type | Name | Description |
---|---|---|
IHasChildren | item | The item to remove from this items Children |
DeleteChild(T)
Removes a child item from the collection of Children in this item
Declaration
public void DeleteChild(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to remove from this items Children |