Class StaticModelCollection<T>
- Namespace
- DuetAPI.ObjectModel
- Assembly
- DuetAPI.dll
Generic container for model object arrays with static items
public class StaticModelCollection<T> : ObservableCollection<T>, IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IModelCollection, IStaticModelObject, IModelObject, ICloneable, INotifyPropertyChanged, INotifyCollectionChanged where T : IStaticModelObject?, new()
Type Parameters
TItem type
- Inheritance
-
Collection<T>StaticModelCollection<T>
- Implements
-
IList<T>ICollection<T>IEnumerable<T>
- Derived
- Inherited Members
Constructors
StaticModelCollection()
Default constructor
public StaticModelCollection()
StaticModelCollection(IEnumerable<T>)
Overloading constructor that takes items for initialization
public StaticModelCollection(IEnumerable<T> collection)
Parameters
collectionIEnumerable<T>Collection to use for items
StaticModelCollection(List<T>)
Overloading constructor that takes a list for initialization
public StaticModelCollection(List<T> list)
Parameters
listList<T>List to use for items
Methods
Assign(IStaticModelObject)
Assign the properties from another instance. This is required to update model properties which do not have a setter
public void Assign(IStaticModelObject from)
Parameters
fromIStaticModelObjectOther instance
ClearItems()
Removes all items from the collection
protected override void ClearItems()
Clone()
Create a clone of this list
public object Clone()
Returns
- object
Cloned list
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raises the change event handler
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
eNotifyCollectionChangedEventArgsEvent arguments
UpdateFromJson(JsonElement, bool)
Update this instance from a given JSON element
public IStaticModelObject? UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties)
Parameters
jsonElementJsonElementElement to update this intance from
ignoreSbcPropertiesboolWhether SBC properties are ignored
Returns
- IStaticModelObject
Updated instance
Remarks
Accepts null as the JSON value to clear existing items
Exceptions
- JsonException
Failed to deserialize data
UpdateFromJson(JsonElement, bool, int, bool)
Update this collection from a given JSON array
public void UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties, int offset = 0, bool last = true)
Parameters
jsonElementJsonElementElement to update this intance from
ignoreSbcPropertiesboolWhether SBC properties are ignored
offsetintIndex offset
lastboolWhether this is the last update
UpdateFromJsonReader(ref Utf8JsonReader, bool)
Update this collection from a given JSON reader
public void UpdateFromJsonReader(ref Utf8JsonReader reader, bool ignoreSbcProperties)
Parameters
readerUtf8JsonReaderJSON reader
ignoreSbcPropertiesboolWhether SBC properties are ignored
UpdateFromJsonReader(ref Utf8JsonReader, bool, int, bool)
Update this collection from a given JSON reader
public void UpdateFromJsonReader(ref Utf8JsonReader reader, bool ignoreSbcProperties, int offset = 0, bool last = true)
Parameters
readerUtf8JsonReaderJSON reader
ignoreSbcPropertiesboolWhether SBC properties are ignored
offsetintIndex offset
lastboolWhether this is the last update