Class ModelObject
Base class for machine model properties
Inheritance
Implements
Inherited Members
Namespace: DuetAPI.Machine
Assembly: DuetAPI.dll
Syntax
public class ModelObject : ICloneable, INotifyPropertyChanging, INotifyPropertyChanged
Constructors
ModelObject()
Default constructor to be called from derived classes
Declaration
public ModelObject()
Fields
JsonProperties
Get the cached JSON properties of this type
Declaration
public readonly Dictionary<string, PropertyInfo> JsonProperties
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Reflection.PropertyInfo> | Properties of this type |
Methods
Assign(ModelObject)
Method to assign the value of one type to another
Declaration
public void Assign(ModelObject from)
Parameters
Type | Name | Description |
---|---|---|
ModelObject | from | Other object |
Clone()
Create a clone of this instance
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | Cloned object |
MakeStringPatch(ModelObject)
Create a string-encoded JSON patch to bring an old instance to this state
Declaration
public string MakeStringPatch(ModelObject old)
Parameters
Type | Name | Description |
---|---|---|
ModelObject | old | Old object state |
Returns
Type | Description |
---|---|
System.String | JSON patch |
MakeUtf8Patch(ModelObject)
Create a UTF8-encoded JSON patch to bring an old instance to this state
Declaration
public byte[] MakeUtf8Patch(ModelObject old)
Parameters
Type | Name | Description |
---|---|---|
ModelObject | old | Old object state |
Returns
Type | Description |
---|---|
System.Byte[] | JSON patch |
SetPropertyValue<T>(ref T, T, String)
Method to update a property value internally
Declaration
protected void SetPropertyValue<T>(ref T propertyStorage, T value, string propertyName = "")
Parameters
Type | Name | Description |
---|---|---|
T | propertyStorage | Reference to the variable that holds the current value |
T | value | New property value |
System.String | propertyName | Name of the property |
Type Parameters
Name | Description |
---|---|
T |
UpdateFromJson(JsonElement)
Update this instance from a given JSON element
Declaration
public ModelObject UpdateFromJson(JsonElement jsonElement)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Json.JsonElement | jsonElement | Element to update this intance from |
Returns
Type | Description |
---|---|
ModelObject | Updated instance |
Events
PropertyChanged
Event that is triggered when a property has been changed
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangedEventHandler |
PropertyChanging
Event that is triggered when a property is being changed
Declaration
public event PropertyChangingEventHandler PropertyChanging
Event Type
Type | Description |
---|---|
System.ComponentModel.PropertyChangingEventHandler |