Table of Contents

Class DynamicModelCollection<T>

Namespace
DuetAPI.ObjectModel
Assembly
DuetAPI.dll

Generic container for model object arrays with dynamic items

public class DynamicModelCollection<T> : ObservableCollection<T>, IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IModelCollection, IStaticModelObject, IModelObject, ICloneable, INotifyPropertyChanged, INotifyCollectionChanged where T : IDynamicModelObject?, new()

Type Parameters

T

Item type

Inheritance
DynamicModelCollection<T>
Implements
Inherited Members

Constructors

DynamicModelCollection()

Default constructor

public DynamicModelCollection()

DynamicModelCollection(IEnumerable<T>)

Overloading constructor that takes items for initialization

public DynamicModelCollection(IEnumerable<T> collection)

Parameters

collection IEnumerable<T>

Collection to use for items

DynamicModelCollection(List<T>)

Overloading constructor that takes a list for initialization

public DynamicModelCollection(List<T> list)

Parameters

list List<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

from IStaticModelObject

Other 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

e NotifyCollectionChangedEventArgs

Event arguments

UpdateFromJson(JsonElement, bool)

Update this instance from a given JSON element

public IStaticModelObject? UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties)

Parameters

jsonElement JsonElement

Element to update this intance from

ignoreSbcProperties bool

Whether 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

jsonElement JsonElement

Element to update this intance from

ignoreSbcProperties bool

Whether SBC properties are ignored

offset int

Index offset

last bool

Whether this is the last update

UpdateFromJsonReader(ref Utf8JsonReader, bool)

Update this instance from a given JSON reader

public void UpdateFromJsonReader(ref Utf8JsonReader reader, bool ignoreSbcProperties)

Parameters

reader Utf8JsonReader

JSON reader

ignoreSbcProperties bool

Whether SBC properties are ignored

Exceptions

JsonException

Failed to deserialize data

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

reader Utf8JsonReader

JSON reader

ignoreSbcProperties bool

Whether SBC properties are ignored

offset int

Index offset

last bool

Whether this is the last update