Class ModelObject
Base class for machine model properties
Inheritance
Inherited Members
Namespace: DuetAPI.ObjectModel
Assembly: DuetAPI.dll
Syntax
public class ModelObject : IModelObject, ICloneable, INotifyPropertyChanged, INotifyPropertyChanging
Properties
JsonProperties
Get the cached JSON properties of this type
Declaration
[JsonIgnore]
public Dictionary<string, PropertyInfo> JsonProperties { get; }
Property Value
Type | Description |
---|---|
Dictionary<string, PropertyInfo> | Properties of this type |
Methods
Assign(object)
Assign the properties from another instance
Declaration
public void Assign(object from)
Parameters
Type | Name | Description |
---|---|---|
object | from | Other instance |
Clone()
Create a clone of this instance
Declaration
public object Clone()
Returns
Type | Description |
---|---|
object | Cloned object |
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
[Obsolete("will be removed in v3.6")]
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 |
MakeStringPatch(ModelObject)
Create a string-encoded JSON patch to bring an old instance to this state
Declaration
[Obsolete("will be removed in v3.6")]
public string MakeStringPatch(ModelObject old)
Parameters
Type | Name | Description |
---|---|---|
ModelObject | old | Old object state |
Returns
Type | Description |
---|---|
string | JSON patch |
MakeUtf8Patch(ModelObject)
Create a UTF8-encoded JSON patch to bring an old instance to this state
Declaration
[Obsolete("will be removed in v3.6")]
public byte[] MakeUtf8Patch(ModelObject old)
Parameters
Type | Name | Description |
---|---|---|
ModelObject | old | Old object state |
Returns
Type | Description |
---|---|
byte[] | JSON patch |
RegisterJsonType(Type)
Function to add custom JSON types. This must be invoked from types with generic type arguments
Declaration
protected static void RegisterJsonType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type to register |
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 |
string | propertyName | Name of the property |
Type Parameters
Name | Description |
---|---|
T |
UpdateFromJson(JsonElement, bool)
Update this instance from a given JSON element
Declaration
public virtual 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 |
Exceptions
Type | Condition |
---|---|
JsonException | Failed to deserialize data |
Events
PropertyChanged
Event that is triggered when a property has been changed
Declaration
public event PropertyChangedEventHandler? PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |
PropertyChanging
Event that is triggered when a property is being changed
Declaration
public event PropertyChangingEventHandler? PropertyChanging
Event Type
Type | Description |
---|---|
PropertyChangingEventHandler |