Class ModelCollection<T>
Generic container for object model arrays
Inherited Members
Namespace: DuetAPI.ObjectModel
Assembly: DuetAPI.dll
Syntax
public class ModelCollection<T> : ObservableCollection<T>, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, IModelCollection, IModelObject, ICloneable, INotifyPropertyChanged, INotifyCollectionChanged
Type Parameters
Name | Description |
---|---|
T | Item type |
Methods
Assign(object)
Assign the properties from another instance. This is required to update model properties which do not have a setter
Declaration
public void Assign(object from)
Parameters
Type | Name | Description |
---|---|---|
object | from | Other instance |
ClearItems()
Removes all items from the collection
Declaration
protected override void ClearItems()
Overrides
Clone()
Create a clone of this list
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object | Cloned list |
FindDifferences(IModelObject)
Create a dictionary or list of all the differences between this instance and another. This method outputs own property values that differ from the other instance
Declaration
public object? FindDifferences(IModelObject other)
Parameters
Type | Name | Description |
---|---|---|
IModelObject | other | Other instance |
Returns
Type | Description |
---|---|
object | Object differences or null if both instances are equal |
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raises the change event handler
Declaration
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
NotifyCollectionChangedEventArgs | e | Event arguments |
Overrides
UpdateFromJson(JsonElement, bool)
Update this instance from a given JSON element
Declaration
public IModelObject? UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | jsonElement | Element to update this intance from |
bool | ignoreSbcProperties | Whether SBC properties are ignored |
Returns
Type | Description |
---|---|
IModelObject | Updated instance |
Remarks
Accepts null as the JSON value to clear existing items
Exceptions
Type | Condition |
---|---|
JsonException | Failed to deserialize data |
UpdateFromJson(JsonElement, bool, int, bool)
Update this collection from a given JSON array
Declaration
public void UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties, int offset = 0, bool last = true)
Parameters
Type | Name | Description |
---|---|---|
JsonElement | jsonElement | Element to update this intance from |
bool | ignoreSbcProperties | Whether SBC properties are ignored |
int | offset | Index offset |
bool | last | Whether this is the last update |