Class ModelObject
Base class for machine model properties
Inheritance
Implements
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 |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Reflection.PropertyInfo> | Properties of this type |
Methods
Assign(Object)
Assign the properties from another instance
Declaration
public void Assign(object from)
Parameters
Type | Name | Description |
---|---|---|
System.Object | from | Other instance |
Clone()
Create a clone of this instance
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.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
public object FindDifferences(IModelObject other)
Parameters
Type | Name | Description |
---|---|---|
IModelObject | other | Other instance |
Returns
Type | Description |
---|---|
System.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
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 |
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 |
---|---|---|
System.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 |
System.String | propertyName | Name of the property |
Type Parameters
Name | Description |
---|---|
T |
UpdateFromJson(JsonElement, Boolean)
Update this instance from a given JSON element
Declaration
public virtual IModelObject UpdateFromJson(JsonElement jsonElement, bool ignoreSbcProperties)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Json.JsonElement | jsonElement | Element to update this intance from |
System.Boolean | ignoreSbcProperties | Whether SBC properties are ignored |
Returns
Type | Description |
---|---|
IModelObject | Updated instance |
Exceptions
Type | Condition |
---|---|
System.Text.Json.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 |
---|---|
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 |