mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Nullable refactoring
Core - Nullable refactoring Core - Nullable refactoring (finish)
This commit is contained in:
1 parent
b185b28645
commit
fb3466e102
61 files changed
+320
-272
No files matched your search
@@ -11,32 +11,32 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// <summary>
|
||||
/// Gets or sets the user-friendly name for this property, shown in the UI.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user-friendly description for this property, shown in the UI.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the an optional prefix to show before displaying elements in the UI.
|
||||
/// </summary>
|
||||
public string Prefix { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional affix to show behind displaying elements in the UI.
|
||||
/// </summary>
|
||||
public string Affix { get; set; }
|
||||
public string? Affix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional maximum value, this value is not enforced but used for percentage calculations.
|
||||
/// </summary>
|
||||
public object MaxValue { get; set; }
|
||||
public object? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional minimum value, this value is not enforced but used for percentage calculations.
|
||||
/// </summary>
|
||||
public object MinValue { get; set; }
|
||||
public object? MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this property resets the max depth of the data model, defaults to true
|
||||
|
||||
@@ -15,6 +15,16 @@ namespace Artemis.Core.DataModelExpansions
|
||||
{
|
||||
private readonly Dictionary<string, DataModel> _dynamicDataModels = new Dictionary<string, DataModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="DataModel" /> class
|
||||
/// </summary>
|
||||
protected DataModel()
|
||||
{
|
||||
// These are both set right after construction to keep the constructor of inherited classes clean
|
||||
Feature = null!;
|
||||
DataModelDescription = null!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin feature this data model belongs to
|
||||
/// </summary>
|
||||
@@ -60,7 +70,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// <param name="key">The key of the child, must be unique to this data model</param>
|
||||
/// <param name="name">An optional name, if not provided the key will be used in a humanized form</param>
|
||||
/// <param name="description">An optional description</param>
|
||||
public T AddDynamicChild<T>(T dynamicDataModel, string key, string name = null, string description = null) where T : DataModel
|
||||
public T AddDynamicChild<T>(T dynamicDataModel, string key, string? name = null, string? description = null) where T : DataModel
|
||||
{
|
||||
if (dynamicDataModel == null)
|
||||
throw new ArgumentNullException(nameof(dynamicDataModel));
|
||||
@@ -140,7 +150,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// <returns>If found, the dynamic data model otherwise <c>null</c></returns>
|
||||
public T? DynamicChild<T>(string key) where T : DataModel
|
||||
{
|
||||
_dynamicDataModels.TryGetValue(key, out DataModel value);
|
||||
_dynamicDataModels.TryGetValue(key, out DataModel? value);
|
||||
return value as T;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Artemis.Core.DataModelExpansions
|
||||
/// </summary>
|
||||
public T DataModel
|
||||
{
|
||||
get => (T) InternalDataModel;
|
||||
get => InternalDataModel as T ?? throw new InvalidOperationException("Internal datamodel does not match the type of the data model");
|
||||
internal set => InternalDataModel = value;
|
||||
}
|
||||
|
||||
@@ -49,11 +49,5 @@ namespace Artemis.Core.DataModelExpansions
|
||||
DataModel.DataModelDescription = GetDataModelDescription();
|
||||
base.InternalEnable();
|
||||
}
|
||||
|
||||
internal override void InternalDisable()
|
||||
{
|
||||
DataModel = null;
|
||||
base.InternalDisable();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user