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
| Name | Description |
|---|---|
T |
- Inheritance
-
objectADTObjectCollectionT<T>
- Derived
Constructors
ADTObjectCollectionT()
protected ADTObjectCollectionT()
ADTObjectCollectionT(ADTObject, string)
protected ADTObjectCollectionT(ADTObject parent, string parentNavigatorName)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
index |
object |
Property Value
- T
Remarks
Returns null if no object with the requested OID is found.
Exceptions
- ArgumentOutOfRangeException
Thrown if
indexis a numeric value that is outside the bounds of the collection.- ArgumentException
Thrown if
indexis 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
| Name | Type | Description |
|---|---|---|
newVal |
T |
Exceptions
- NotSupportedException
The System.Collections.Generic.ICollection<T> is read-only.
AddRange(IEnumerable<T>)
public void AddRange(IEnumerable<T> source)
Parameters
| Name | Type | Description |
|---|---|---|
source |
IEnumerable<T> |
CanAdd(T)
protected virtual bool CanAdd(T obj)
Parameters
| Name | Type | Description |
|---|---|---|
obj |
T |
Returns
- bool
CanRemove(T)
protected virtual bool CanRemove(T obj)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
targetOID |
OID | The OID to check for |
Returns
- bool
EnsureCanReferenceAndThrow(ADTObject)
protected void EnsureCanReferenceAndThrow(ADTObject objectToReference)
Parameters
| Name | Type | Description |
|---|---|---|
objectToReference |
ADTObject |
GetAt(int)
Gets the object at the specified index
public T GetAt(int index)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
index |
object |
Returns
- T
Remarks
Returns null if no object with the requested OID is found.
Exceptions
- ArgumentOutOfRangeException
Thrown if
indexis a numeric value that is outside the bounds of the collection.- ArgumentException
Thrown if
indexis 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
oid |
OID | The OID of the object to get from the collection. |
Returns
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
| Name | Type | Description |
|---|---|---|
index |
int | The zero-based index at which |
newVal |
T |
Exceptions
- ArgumentOutOfRangeException
indexis less than 0.
-or-
indexis 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
| Name | Type | Description |
|---|---|---|
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
oldIndexornewIndexis not a valid index.
OnObjectAdded(T, int)
protected virtual void OnObjectAdded(T newVal, int index)
Parameters
| Name | Type | Description |
|---|---|---|
newVal |
T | |
index |
int |
OnObjectRemoved(T)
protected virtual void OnObjectRemoved(T newVal)
Parameters
| Name | Type | Description |
|---|---|---|
newVal |
T |
Remove(object)
Removes the specified object, OID, or index
public void Remove(object index)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
ObjectToRemove |
T |
Returns
- bool
true if
itemwas successfully removed from the System.Collections.Generic.ICollection<T>; otherwise, false. This method also returns false ifitemis 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
| Name | Type | Description |
|---|---|---|
index |
int | The zero-based index of the element to remove. |
Exceptions
- ArgumentOutOfRangeException
indexis less than 0.
-or-
indexis 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
| Name | Type | Description |
|---|---|---|
targetOID |
OID |
Returns
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
| Name | Type | Description |
|---|---|---|
comparer |
IComparer<T> |
Sort(Comparison<T>)
public void Sort(Comparison<T> comparer)
Parameters
| Name | Type | Description |
|---|---|---|
comparer |
Comparison<T> |
Sort(int, int, IComparer<T>)
public void Sort(int index, int count, IComparer<T> comparer)
Parameters
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
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
EntityRemoved
public event ADTObjectCollectionT<T>.CollectionOperationEvent EntityRemoved
Event Type
ObjectAdding
public event ADTObjectCollectionT<T>.CancelableCollectionOperationEvent ObjectAdding
Event Type
ObjectRemoving
public event ADTObjectCollectionT<T>.CancelableCollectionOperationEvent ObjectRemoving
Event Type
Inherited Members
- ObjectCollectionT<T>.Collection
- ObjectCollectionT<T>.ParentFacade
- ObjectCollectionT<T>.NavigatorName
- ObjectCollectionT<T>.IsReadOnly
- ObjectCollectionT<T>.Contains(T)
- ObjectCollectionT<T>.CopyTo(T[], int)
- ObjectCollectionT<T>.Count
- ObjectCollectionT<T>.CheckReadOnlyAndThrow()
- ObjectCollectionT<T>.MoveUp(T)
- ObjectCollectionT<T>.MoveDown(T)
- ObjectCollectionT<T>.MoveItem(T, int)
- ObjectCollectionT<T>.this[int]
- ObjectCollectionT<T>.IndexOf(T)