Class List
- Namespace
- Dynamitey.DynamicObjects
- Assembly
- Dynamitey.Community.dll
Expando-Type List for dynamic objects
public class List : BaseDictionary, IDynamicMetaObjectProvider, IEquivalentType, INotifyPropertyChanged, IList<object>, ICollection<object>, IEnumerable<object>, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, INotifyCollectionChanged, IList, ICollection, IEnumerable
- Inheritance
-
List
- Implements
- Inherited Members
- Extension Methods
Constructors
List(IEnumerable<object>?, IEnumerable<KeyValuePair<string, object>>?)
Initializes a new instance of the List class.
[RequiresDynamicCode("Constructing any BaseObject-derived type instantiates System.Dynamic.DynamicObject, whose default constructor requires the DLR's runtime code generation; not supported when AOT-compiled.")]
public List(IEnumerable<object>? contents = null, IEnumerable<KeyValuePair<string, object>>? members = null)
Parameters
contentsIEnumerable<dynamic>The contents.
membersIEnumerable<KeyValuePair<string, object>>The members.
Fields
_list
Wrapped list
protected IList<object> _list
Field Value
Properties
Count
Gets the count.
public int Count { get; }
Property Value
- int
The count.
IsFixedSize
Gets a value indicating whether this instance is fixed size.
public bool IsFixedSize { get; }
Property Value
- bool
trueif this instance is fixed size; otherwise,false.
IsSynchronized
Gets a value indicating whether this instance is synchronized.
public bool IsSynchronized { get; }
Property Value
- bool
trueif this instance is synchronized; otherwise,false.
this[int]
Gets or sets the object at the specified index.
public dynamic this[int index] { get; set; }
Parameters
indexintThe index.
Property Value
- dynamic
The object.
OverrideGettingItemMethodNames
Gets or sets the override getting item method names. USED for GetItemProperties
public Func<IEnumerable<object>, IEnumerable<string>>? OverrideGettingItemMethodNames { get; set; }
Property Value
- Func<IEnumerable<object>, IEnumerable<string>>
The override getting item method names.
SyncRoot
Gets the sync root.
public object SyncRoot { get; }
Property Value
- object
The sync root.
Methods
Add(dynamic)
Adds the specified item.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The item parameter is statically typed 'dynamic', so this call binds through the DLR binder even though the underlying operation is a plain list add. Can't carry [RequiresUnreferencedCode] itself: it implements a plain BCL collection interface member that isn't annotated, and the two must match. The actionable warning belongs to whichever 'dynamic'-typed argument the caller supplied, which already carries this requirement at its own declaration.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same reasoning as the IL2026 suppression on this member.")]
public void Add(dynamic item)
Parameters
itemdynamicThe item.
Clear()
Clears this instance.
public void Clear()
Contains(dynamic?)
Determines whether [contains] [the specified item].
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The item parameter is statically typed 'dynamic', so this call binds through the DLR binder even though the underlying operation is a plain list lookup. Can't carry [RequiresUnreferencedCode] itself: it implements a plain BCL collection interface member that isn't annotated, and the two must match. The actionable warning belongs to whichever 'dynamic'-typed argument the caller supplied, which already carries this requirement at its own declaration.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same reasoning as the IL2026 suppression on this member.")]
public bool Contains(dynamic? item)
Parameters
itemdynamicThe item.
Returns
- bool
trueif [contains] [the specified item]; otherwise,false.
CopyTo(Array, int)
Copies to.
public void CopyTo(Array array, int index)
Parameters
CopyTo(object[], int)
Copies to.
public void CopyTo(object[] array, int arrayIndex)
Parameters
Equals(List?)
Determines whether the specified List is equal to this instance.
public bool Equals(List? other)
Parameters
otherListThe other.
Returns
- bool
truewhen both instances are views over the same backing stores - the same IList<T> of elements and the same dictionary of dynamic properties.
Remarks
This is deliberately store identity, not content comparison: these types are mutable views over a store someone else owns, so two wrappers over one store are one value, while two stores that merely happen to hold equal data are not. Comparing content would also force a content-derived GetHashCode() on a mutable type, which makes an instance unfindable in a hash container as soon as it is mutated.
This previously opened with base.Equals(other), which resolves to
Equals(object?) - a method whose body type-tests against
typeof(Dictionary) and so, for a List, compared the backing
dictionary against the List itself and returned false. That made the whole
method return false unconditionally and left the element comparison below it
unreachable, even for two wrappers over one IList<T>. See issue #52.
Equals(object?)
Determines whether the specified object is equal to this instance.
public override bool Equals(object? obj)
Parameters
Returns
GetEnumerator()
Gets the enumerator.
public IEnumerator<dynamic> GetEnumerator()
Returns
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
GetRepresentedItem()
Gets the represented item. USED fOR GetItemProperties
protected virtual dynamic? GetRepresentedItem()
Returns
- dynamic
IndexOf(dynamic?)
Indexes the of.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The item parameter is statically typed 'dynamic', so this call binds through the DLR binder even though the underlying operation is a plain list lookup. Can't carry [RequiresUnreferencedCode] itself: it implements a plain BCL collection interface member that isn't annotated, and the two must match. The actionable warning belongs to whichever 'dynamic'-typed argument the caller supplied, which already carries this requirement at its own declaration.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same reasoning as the IL2026 suppression on this member.")]
public int IndexOf(dynamic? item)
Parameters
itemdynamicThe item.
Returns
Insert(int, dynamic?)
Inserts the specified index.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The item parameter is statically typed 'dynamic', so this call binds through the DLR binder even though the underlying operation is a plain list insert. Can't carry [RequiresUnreferencedCode] itself: it implements a plain BCL collection interface member that isn't annotated, and the two must match. The actionable warning belongs to whichever 'dynamic'-typed argument the caller supplied, which already carries this requirement at its own declaration.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same reasoning as the IL2026 suppression on this member.")]
public void Insert(int index, dynamic? item)
Parameters
indexintThe index.
itemdynamicThe item.
OnCollectionChanged(NotifyCollectionChangedAction, object?, object?, int?, int?)
Called when [collection changed].
protected virtual void OnCollectionChanged(NotifyCollectionChangedAction action, object? oldItem = null, object? newItem = null, int? oldIndex = null, int? newIndex = null)
Parameters
actionNotifyCollectionChangedActionThe action.
oldItemobjectThe old item.
newItemobjectThe new item.
oldIndexint?The old index.
newIndexint?The new index.
Remove(dynamic)
Removes the specified item.
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The item parameter is statically typed 'dynamic', so this call binds through the DLR binder even though the underlying operation is a plain list remove. Can't carry [RequiresUnreferencedCode] itself: it implements a plain BCL collection interface member that isn't annotated, and the two must match. The actionable warning belongs to whichever 'dynamic'-typed argument the caller supplied, which already carries this requirement at its own declaration.")]
[UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Same reasoning as the IL2026 suppression on this member.")]
public bool Remove(dynamic item)
Parameters
itemdynamicThe item.
Returns
RemoveAt(int)
Removes at.
public void RemoveAt(int index)
Parameters
indexintThe index.
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler? CollectionChanged