Class BaseHasChildren<T>
A base class that items can inherit from that implements the IHasChildren<T> functionality
Inheritance
Inherited Members
Namespace: LemonEdge.Utils
Assembly: 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(T)
Creates a new BaseHasChildren item with the specified BaseHasChildren item as its Parent item
Declaration
public 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 |
BaseHasChildren(Func<T, Int32>)
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 |
---|---|---|
System.Func<T, System.Int32> | getOrder | A function that given a child item returns the order it should be enumerated in when enumerating Children |
BaseHasChildren(Func<T, Int32>, 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
public BaseHasChildren(Func<T, int> getOrder, T parent)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.Int32> | 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 |
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 |
---|---|
System.Collections.Generic.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 |
---|---|
System.Func<T, System.Int32> |
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(T)
Adds a child item to the collection of Children in this item
Declaration
public void AddChild(T item)
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 |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the item to be added already has another Parent an exception is thrown |
AddChild(IHasChildren)
Declaration
public void AddChild(IHasChildren item)
Parameters
Type | Name | Description |
---|---|---|
IHasChildren | item |
ClearChildren()
Clears all children contained within this item
Declaration
public void ClearChildren()
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 |
DeleteChild(IHasChildren)
Declaration
public void DeleteChild(IHasChildren item)
Parameters
Type | Name | Description |
---|---|---|
IHasChildren | item |
Explicit Interface Implementations
IHasChildren.Children
Declaration
IEnumerable<IHasChildren> IHasChildren.Children { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IHasChildren> |
IHasChildren.Parent
Declaration
IHasChildren IHasChildren.Parent { get; }
Returns
Type | Description |
---|---|
IHasChildren |