Class DataModel
Represents a data model that contains information on a game/application etc.
Namespace: Artemis.Core.Modules
Assembly: Artemis.Core.dll
Syntax
public abstract class DataModel
Constructors
DataModel()
Creates a new instance of the DataModel class
Declaration
protected DataModel()
Properties
ActivePaths
Gets a read-only list of DataModelPaths targeting this data model
Declaration
[DataModelIgnore]
public ReadOnlyCollection<DataModelPath> ActivePaths { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<DataModelPath> |
DataModelDescription
Gets the DataModelPropertyAttribute describing this data model
Declaration
[JsonIgnore]
[DataModelIgnore]
public DataModelPropertyAttribute DataModelDescription { get; }
Property Value
Type | Description |
---|---|
DataModelPropertyAttribute |
DynamicChildren
Gets an read-only dictionary of all dynamic children
Declaration
[DataModelIgnore]
public ReadOnlyDictionary<string, DynamicChild> DynamicChildren { get; }
Property Value
Type | Description |
---|---|
ReadOnlyDictionary<string, DynamicChild> |
IsExpansion
Gets the is expansion status indicating whether this data model expands the main data model
Declaration
[DataModelIgnore]
public bool IsExpansion { get; }
Property Value
Type | Description |
---|---|
bool |
Module
Gets the module this data model belongs to
Declaration
[JsonIgnore]
[DataModelIgnore]
public Module Module { get; }
Property Value
Type | Description |
---|---|
Module |
Methods
AddDynamicChild<T>(string, T)
Adds a dynamic child to this data model
Declaration
public DynamicChild<T> AddDynamicChild<T>(string key, T initialValue)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the child, must be unique to this data model |
T | initialValue | The initial value of the dynamic child |
Returns
Type | Description |
---|---|
DynamicChild<T> | The resulting dynamic child which can be used to further update the value |
Type Parameters
Name | Description |
---|---|
T |
AddDynamicChild<T>(string, T, DataModelPropertyAttribute)
Adds a dynamic child to this data model
Declaration
public DynamicChild<T> AddDynamicChild<T>(string key, T initialValue, DataModelPropertyAttribute attribute)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the child, must be unique to this data model |
T | initialValue | The initial value of the dynamic child |
DataModelPropertyAttribute | attribute | A data model property attribute describing the dynamic child |
Returns
Type | Description |
---|---|
DynamicChild<T> | The resulting dynamic child which can be used to further update the value |
Type Parameters
Name | Description |
---|---|
T |
AddDynamicChild<T>(string, T, string, string?)
Adds a dynamic child to this data model
Declaration
public DynamicChild<T> AddDynamicChild<T>(string key, T initialValue, string name, string? description = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the child, must be unique to this data model |
T | initialValue | The initial value of the dynamic child |
string | name | A human readable name for your dynamic child, shown in the UI |
string | description | An optional description, shown in the UI |
Returns
Type | Description |
---|---|
DynamicChild<T> | The resulting dynamic child which can be used to further update the value |
Type Parameters
Name | Description |
---|---|
T |
ClearDynamicChildren()
Removes all dynamic children from this data model
Declaration
public void ClearDynamicChildren()
GetDynamicChild(string)
Gets a previously added dynamic child by its key
Declaration
public DynamicChild GetDynamicChild(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the dynamic child |
Returns
Type | Description |
---|---|
DynamicChild |
GetDynamicChild<T>(string)
Gets a previously added dynamic child by its key
Declaration
public DynamicChild<T> GetDynamicChild<T>(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the dynamic child |
Returns
Type | Description |
---|---|
DynamicChild<T> |
Type Parameters
Name | Description |
---|---|
T | The typer of dynamic child you are expecting |
GetHiddenProperties()
Returns a read-only collection of all properties in this datamodel that are to be ignored
Declaration
public ReadOnlyCollection<PropertyInfo> GetHiddenProperties()
Returns
Type | Description |
---|---|
ReadOnlyCollection<PropertyInfo> |
GetPropertyDescription(PropertyInfo)
Gets the property description of the provided property info
Declaration
public virtual DataModelPropertyAttribute? GetPropertyDescription(PropertyInfo propertyInfo)
Parameters
Type | Name | Description |
---|---|---|
PropertyInfo | propertyInfo |
Returns
Type | Description |
---|---|
DataModelPropertyAttribute | If found, the property description attribute, otherwise null. |
OnActivePathAdded(DataModelPathEventArgs)
Invokes the ActivePathAdded event
Declaration
protected virtual void OnActivePathAdded(DataModelPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DataModelPathEventArgs | e |
OnActivePathRemoved(DataModelPathEventArgs)
Invokes the ActivePathRemoved event
Declaration
protected virtual void OnActivePathRemoved(DataModelPathEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DataModelPathEventArgs | e |
OnDynamicDataModelAdded(DynamicDataModelChildEventArgs)
Invokes the DynamicChildAdded event
Declaration
protected virtual void OnDynamicDataModelAdded(DynamicDataModelChildEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DynamicDataModelChildEventArgs | e |
OnDynamicDataModelRemoved(DynamicDataModelChildEventArgs)
Invokes the DynamicChildRemoved event
Declaration
protected virtual void OnDynamicDataModelRemoved(DynamicDataModelChildEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DynamicDataModelChildEventArgs | e |
RemoveDynamicChild(DynamicChild)
Removes a dynamic child from this data model
Declaration
public void RemoveDynamicChild(DynamicChild dynamicChild)
Parameters
Type | Name | Description |
---|---|---|
DynamicChild | dynamicChild | The dynamic data child to remove |
RemoveDynamicChildByKey(string)
Removes a dynamic child from the data model by its key
Declaration
public void RemoveDynamicChildByKey(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the dynamic child to remove |
TryGetDynamicChild(string, out DynamicChild)
Gets a previously added dynamic child by its key
Declaration
public bool TryGetDynamicChild(string key, out DynamicChild dynamicChild)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the dynamic child |
DynamicChild | dynamicChild | When this method returns, the DynamicChild associated with the specified key, if the key is found; otherwise, null. This parameter is passed uninitialized. |
Returns
Type | Description |
---|---|
bool | true if the data model contains the dynamic child; otherwise false |
TryGetDynamicChild<T>(string, out DynamicChild<T>)
Gets a previously added dynamic child by its key
Declaration
public bool TryGetDynamicChild<T>(string key, out DynamicChild<T> dynamicChild)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key of the dynamic child |
DynamicChild<T> | dynamicChild | When this method returns, the DynamicChild<T> associated with the specified key, if the key is found and the type matches; otherwise, null. This parameter is passed uninitialized. |
Returns
Type | Description |
---|---|
bool | true if the data model contains the dynamic child; otherwise false |
Type Parameters
Name | Description |
---|---|
T | The typer of dynamic child you are expecting |
Events
ActivePathAdded
Occurs when a dynamic child has been added to this data model
Declaration
public event EventHandler<DataModelPathEventArgs>? ActivePathAdded
Event Type
Type | Description |
---|---|
EventHandler<DataModelPathEventArgs> |
ActivePathRemoved
Occurs when a dynamic child has been removed from this data model
Declaration
public event EventHandler<DataModelPathEventArgs>? ActivePathRemoved
Event Type
Type | Description |
---|---|
EventHandler<DataModelPathEventArgs> |
DynamicChildAdded
Occurs when a dynamic child has been added to this data model
Declaration
public event EventHandler<DynamicDataModelChildEventArgs>? DynamicChildAdded
Event Type
Type | Description |
---|---|
EventHandler<DynamicDataModelChildEventArgs> |
DynamicChildRemoved
Occurs when a dynamic child has been removed from this data model
Declaration
public event EventHandler<DynamicDataModelChildEventArgs>? DynamicChildRemoved
Event Type
Type | Description |
---|---|
EventHandler<DynamicDataModelChildEventArgs> |