AdvisableCollection<T> Class |
PostSharp.Patterns.DynamicAdvising.DynamicallyAdvisableObject
PostSharp.Patterns.Collections.AdvisableCollection<T>
PostSharp.Patterns.Collections.AdvisableKeyedCollection<TKey, TItem>
Namespace: PostSharp.Patterns.Collections
Assembly: PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 6.7.12.0 (6.7.12.0)
[SerializableAttribute] public class AdvisableCollection<T> : DynamicallyAdvisableObject, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IList, ICollection, IDynamicallyAdvisableCollection, IDynamicallyAdvisable, IQueryInterface, INotifyPropertyChanged, IReadOnlyList<T>, IReadOnlyCollection<T>, INotifyCollectionChanged
Type Parameters
- T
- The type of elements in the collection
The AdvisableCollection<T> type exposes the following members.
Name | Description | |
---|---|---|
Count | Gets the number of elements contained in the ICollection<T>. | |
IsReadOnly | Gets a value indicating whether the ICollection<T> is read-only. | |
Item | Gets or sets the element at the specified index. |
Name | Description | |
---|---|---|
Add | Adds an item to the ICollection<T>. | |
AddRange |
Adds the elements of the specified collection to the end of the AdvisableCollection<T>.
| |
Clear | Removes all items from the ICollection<T>. | |
ClearItems |
Removes all elements from the underlying collection.
| |
Contains | Determines whether the ICollection<T> contains a specific value. | |
CopyTo | ||
ExecuteWithAdvices<TResult, TAction> |
Executes an action wrapped by all custom advices added to the current object.
(Inherited from DynamicallyAdvisableObject.) | |
GetAdviceEnumerator |
Gets an AdviceEnumerator<T> for the ICollectionDynamicAdvice<T> interface.
| |
GetCount |
Gets the number of elements in the underlying collection.
| |
GetEnumerator |
Returns an enumerator that iterates through the AdvisableCollection<T>.
| |
GetItem |
Gets the element at the specified index of the underlying collection.
| |
GetObjectData | Populates a SerializationInfo with the data needed to serialize the target object. (Overrides DynamicallyAdvisableObject.GetObjectData(SerializationInfo, StreamingContext).) | |
GetRange |
Creates a shallow copy of a range of elements in the source AdvisableCollection<T>.
| |
IndexOf | Determines the index of a specific item in the IList<T>. | |
IndexOfItem |
Searches for the specified object and returns the zero-based index of the first occurrence within the entire underlying collection.
| |
InitializeAdvices |
Initializes the list of dynamic advices.
(Inherited from DynamicallyAdvisableObject.) | |
Insert | Inserts an item to the IList<T> at the specified index. | |
InsertItem |
Inserts an element into the underlying collection at the specified index.
| |
InsertItems |
Inserts elements into the underlying collection at the specified index.
| |
InsertRange |
Inserts the elements of a collection into the AdvisableCollection<T> at the specified index.
| |
Move |
Moved the element at the specified index to another index.
| |
MoveItem |
Moves the element at the specified index to another index in the underlying collection.
| |
OnDeserialization | Runs when the entire object graph has been deserialized. (Overrides DynamicallyAdvisableObject.OnDeserialization(Object).) | |
RaiseEvents |
Raised the events that have been buffered.
| |
Remove | Removes the first occurrence of a specific object from the ICollection<T>. | |
RemoveAt | Removes the IList<T> item at the specified index. | |
RemoveItem |
Removes the element at the specified index of the underlying collection.
| |
RemoveItems |
Removes the specified number of elements starting at the specified index of the underlying collection.
| |
RemoveRange |
Removes a range of elements from the AdvisableCollection<T>.
| |
SetItem |
Replaces the element at the specified index of the underlying collection.
| |
ToArray |
Creates an array from the current AdvisableCollection<T>.
|
Name | Description | |
---|---|---|
CollectionChanged | Occurs when the collection changes. | |
PropertyChanged |
Event raised when the value of a property of the current object changes.
|
Name | Description | |
---|---|---|
ToAdvisableCollection<T> |
Converts an IEnumerable<T> into an AdvisableCollection<T>.
(Defined by Extensions.) | |
ToAdvisableDictionary<T, TKey, TValue> |
Converts an IEnumerable<T> into a AdvisableDictionary<TKey, TValue> given a method returning the item key and a method returning the item value.
(Defined by Extensions.) | |
ToAdvisableHashSet<T> |
Converts an IEnumerable<T> into an AdvisableHashSet<T>.
(Defined by Extensions.) |
The API of this class is compatible with the Collection<T> class. It provides some additions but preserves the same design and naming conventions.
Classes that derive from AdvisableCollection<T> can add functionalities by overriding protected methods or by defining new public methods. New public methods wrap their logic in a call of the ExecuteWithAdvices<TResult, TAction>(ObjectAccessLevel, TAction) method, which applies boundary aspects. Public methods can access the data structure thanks to protected methods, which have a name ending in Item, for instance SetItem(Int32, T). Public methods should not use other public methods of the class, as it may cause inconsistent invocation of advises and performance issues. Events (PropertyChanged and CollectionChanged( are buffered. Public methods must invoke RaiseEvents() to raise buffered events.