Table of Contents

Class ADTObjectCollectionT<T>

Namespace
ArcanaDevelopment.adTempus.Client.Collections
Assembly
ArcanaDevelopment.adTempus.Client.dll

Base class for collections of ADTObject

public abstract class ADTObjectCollectionT<T> : ObjectCollectionT<T> where T : ADTObject

Type Parameters

NameDescription
T
Inheritance
object
ADTObjectCollectionT<T>
Derived

Constructors

ADTObjectCollectionT()

protected ADTObjectCollectionT()

ADTObjectCollectionT(ADTObject, string)

protected ADTObjectCollectionT(ADTObject parent, string parentNavigatorName)

Parameters

NameTypeDescription
parent ADTObject
parentNavigatorName string

Fields

NumberInReverse

When set to true, RenumberContents() orders the contents in reverse order.

protected bool NumberInReverse

Field Value

bool

NumberingMultiplier

Specifies the multiplier used by RenumberContents (the gap between items)

protected int NumberingMultiplier

Field Value

int

NumberingStart

Specifies the starting index for RenumberContents

protected int NumberingStart

Field Value

int

Properties

this[object]

Gets the object with the specified OID or numeric index.

public virtual T this[object index] { get; }

Parameters

NameTypeDescription
index object

Property Value

T

Remarks

Returns null if no object with the requested OID is found.

Exceptions

ArgumentOutOfRangeException

Thrown if index is a numeric value that is outside the bounds of the collection.

ArgumentException

Thrown if index is not an integer, string, or OID.

See Also

Methods

Add(T)

Adds an item to the System.Collections.Generic.ICollection<T>.

public override void Add(T newVal)

Parameters

NameTypeDescription
newVal T

Exceptions

NotSupportedException

The System.Collections.Generic.ICollection<T> is read-only.

AddRange(IEnumerable<T>)

public void AddRange(IEnumerable<T> source)

Parameters

NameTypeDescription
source IEnumerable<T>

CanAdd(T)

protected virtual bool CanAdd(T obj)

Parameters

NameTypeDescription
obj T

Returns

bool

CanRemove(T)

protected virtual bool CanRemove(T obj)

Parameters

NameTypeDescription
obj T

Returns

bool

Clear()

Removes all objects from the collection

public override void Clear()

Remarks

If the collection contains dependent objects, those objects will be deleted when the parent object is saved. There is no concept of removing dependent objects from the collection without deleting them because they do not exist independently of their parent object.

Contains(OID)

Determines whether the collection contains the object with the specified OID

public virtual bool Contains(OID targetOID)

Parameters

NameTypeDescription
targetOID OID

The OID to check for

Returns

bool

EnsureCanReferenceAndThrow(ADTObject)

protected void EnsureCanReferenceAndThrow(ADTObject objectToReference)

Parameters

NameTypeDescription
objectToReference ADTObject

GetAt(int)

Gets the object at the specified index

public T GetAt(int index)

Parameters

NameTypeDescription
index int

Returns

T

GetEnumerator()

Returns an enumerator that iterates through the collection.

public virtual IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An enumerator that can be used to iterate through the collection.

GetItem(object)

Gets the object with the specified OID or numeric index.

public virtual T GetItem(object index)

Parameters

NameTypeDescription
index object

Returns

T

Remarks

Returns null if no object with the requested OID is found.

Exceptions

ArgumentOutOfRangeException

Thrown if index is a numeric value that is outside the bounds of the collection.

ArgumentException

Thrown if index is not an integer, string, or OID.

GetItemByOID(OID)

Returns the item in the collection that matches the specified OID.

protected virtual T GetItemByOID(OID targetOID)

Parameters

NameTypeDescription
targetOID OID

The OID of the object to get from the collection.

Returns

T

The requested item, or null if the item does not exist in the collection.

Remarks

This method is used by both this[], GetItem, Contains, Remove, etc. Override it to modify the way searches by OID are done.

For example, a collection of joins may want to be able to match on the OID of the join object or one of the objects the join points to.

GetObject(OID)

Gets the object with the specified OID.

public virtual ADTObject GetObject(OID oid)

Parameters

NameTypeDescription
oid OID

The OID of the object to get from the collection.

Returns

ADTObject

The requested object, or null if the object is not found in the collection.

Insert(int, T)

Inserts an element into the System.Collections.Generic.List<T> at the specified index.

public override void Insert(int index, T newVal)

Parameters

NameTypeDescription
index int

The zero-based index at which item should be inserted.

newVal T

Exceptions

ArgumentOutOfRangeException

index is less than 0.
-or-
index is greater than System.Collections.Generic.List<T>.Count.

MoveItem(int, int)

Moves an item within the collection

public override void MoveItem(int oldIndex, int newIndex)

Parameters

NameTypeDescription
oldIndex int

The index to move the item from. Must be a valid index for the collection.

newIndex int

The index to move the item to. Must be a valid index for the collection.

Exceptions

ArgumentOutOfRangeException

Thrown if oldIndex or newIndex is not a valid index.

OnObjectAdded(T, int)

protected virtual void OnObjectAdded(T newVal, int index)

Parameters

NameTypeDescription
newVal T
index int

OnObjectRemoved(T)

protected virtual void OnObjectRemoved(T newVal)

Parameters

NameTypeDescription
newVal T

Remove(object)

Removes the specified object, OID, or index

public void Remove(object index)

Parameters

NameTypeDescription
index object

An object, OID, or numeric index. See Remarks.

Remarks

The index can be any of the following:

  • An object of type T. If an object with the same OID Is found it is removed from the collection. Note that this match does not use reference equality: if you pass a different copy of the object that has the same OID as an object in the collection, the object in the collection will be removed.
  • An OID or a string representation of an OID. The object with the specified OID is removed if present
  • An integer index. The object at the specified index is removed.

Remove(T)

Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.

public override bool Remove(T ObjectToRemove)

Parameters

NameTypeDescription
ObjectToRemove T

Returns

bool

true if item was successfully removed from the System.Collections.Generic.ICollection<T>; otherwise, false. This method also returns false if item is not found in the original System.Collections.Generic.ICollection<T>.

Exceptions

NotSupportedException

The System.Collections.Generic.ICollection<T> is read-only.

RemoveAt(int)

Removes the element at the specified index of the System.Collections.Generic.List<T>.

public override void RemoveAt(int index)

Parameters

NameTypeDescription
index int

The zero-based index of the element to remove.

Exceptions

ArgumentOutOfRangeException

index is less than 0.
-or-
index is equal to or greater than System.Collections.Generic.List<T>.Count.

RemoveByOID(OID)

Removes the object with the specified OID

public virtual bool RemoveByOID(OID targetOID)

Parameters

NameTypeDescription
targetOID OID

Returns

bool

true if the object was removed, false if it was not found in the collection

RenumberContents()

Updates sequence numbers for all items in collection.

protected virtual void RenumberContents()

Remarks

RenumberContents iterates through all items in the collection if they implement the ISequencedCollectionMember. If so, ISequencedCollectionMember.SetSequenceNumber is called. This is used, for example, in a collection of JobSteps, where the StepNumber needs to be set on each step to keep them in the correct order.

Sort(IComparer<T>)

public void Sort(IComparer<T> comparer)

Parameters

NameTypeDescription
comparer IComparer<T>

Sort(Comparison<T>)

public void Sort(Comparison<T> comparer)

Parameters

NameTypeDescription
comparer Comparison<T>

Sort(int, int, IComparer<T>)

public void Sort(int index, int count, IComparer<T> comparer)

Parameters

NameTypeDescription
index int
count int
comparer IComparer<T>

UpdateFrom(IEnumerable<T>)

Updates the collection to match the specified source by adding, deleting, and reordering contents as needed.

public virtual void UpdateFrom(IEnumerable<T> source)

Parameters

NameTypeDescription
source IEnumerable<T>

The source to update from

Remarks

This method behaves differently from AddRange (which only adds to an existing collection). It makes the contents of the target collection match the contents of the source collection by adding and removing objects as necessary.

See Also

UpdateFrom(IEnumerable, bool)

Updates the collection to match the specified source by adding, deleting, and reordering contents as needed.

public virtual void UpdateFrom(IEnumerable source, bool throwOnMismatch)

Parameters

NameTypeDescription
source IEnumerable

An enumerable collection to add from

throwOnMismatch bool

If true, the method throws an InvalidOperationException if it encounters an item that is not of type T. If false, invalid items are silently ignored.

Remarks

This method behaves differently from AddRange (which only adds to an existing collection). It makes the contents of the target collection match the contents of the source collection by adding and removing objects as necessary.

See Also

Events

EntityAdded

public event ADTObjectCollectionT<T>.CollectionOperationEvent EntityAdded

Event Type

ADTObjectCollectionT<T>.CollectionOperationEvent

EntityRemoved

public event ADTObjectCollectionT<T>.CollectionOperationEvent EntityRemoved

Event Type

ADTObjectCollectionT<T>.CollectionOperationEvent

ObjectAdding

public event ADTObjectCollectionT<T>.CancelableCollectionOperationEvent ObjectAdding

Event Type

ADTObjectCollectionT<T>.CancelableCollectionOperationEvent

ObjectRemoving

public event ADTObjectCollectionT<T>.CancelableCollectionOperationEvent ObjectRemoving

Event Type

ADTObjectCollectionT<T>.CancelableCollectionOperationEvent

Inherited Members

Extension Methods