mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +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
@@ -34,7 +34,7 @@ namespace Artemis.Core.Services
|
||||
return ConditionOperatorStore.GetForType(type, side).Select(r => r.ConditionOperator).ToList();
|
||||
}
|
||||
|
||||
public BaseConditionOperator GetConditionOperator(Guid operatorPluginGuid, string operatorType)
|
||||
public BaseConditionOperator? GetConditionOperator(Guid operatorPluginGuid, string operatorType)
|
||||
{
|
||||
return ConditionOperatorStore.Get(operatorPluginGuid, operatorType)?.ConditionOperator;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Artemis.Core.Services
|
||||
return DataBindingModifierTypeStore.GetForType(type, part).Select(r => r.DataBindingModifierType).ToList();
|
||||
}
|
||||
|
||||
public BaseDataBindingModifierType GetModifierType(Guid modifierTypePluginGuid, string modifierType)
|
||||
public BaseDataBindingModifierType? GetModifierType(Guid modifierTypePluginGuid, string modifierType)
|
||||
{
|
||||
return DataBindingModifierTypeStore.Get(modifierTypePluginGuid, modifierType)?.DataBindingModifierType;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Artemis.Core.Services
|
||||
public DataModelService(IPluginManagementService pluginManagementService)
|
||||
{
|
||||
// Add data models of already loaded plugins
|
||||
foreach (Module module in pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled))
|
||||
foreach (Module module in pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled && p.InternalDataModel != null))
|
||||
AddModuleDataModel(module);
|
||||
foreach (BaseDataModelExpansion dataModelExpansion in pluginManagementService.GetFeaturesOfType<BaseDataModelExpansion>().Where(p => p.IsEnabled))
|
||||
AddDataModelExpansionDataModel(dataModelExpansion);
|
||||
@@ -40,9 +40,9 @@ namespace Artemis.Core.Services
|
||||
return DataModelStore.GetAll().Select(d => d.DataModel).ToList();
|
||||
}
|
||||
|
||||
public T GetDataModel<T>() where T : DataModel
|
||||
public T? GetDataModel<T>() where T : DataModel
|
||||
{
|
||||
return (T) DataModelStore.GetAll().FirstOrDefault(d => d.DataModel is T)?.DataModel;
|
||||
return (T?) DataModelStore.GetAll().FirstOrDefault(d => d.DataModel is T)?.DataModel;
|
||||
}
|
||||
|
||||
public DataModel? GetPluginDataModel(PluginFeature pluginFeature)
|
||||
@@ -61,8 +61,7 @@ namespace Artemis.Core.Services
|
||||
private void AddModuleDataModel(Module module)
|
||||
{
|
||||
if (module.InternalDataModel == null)
|
||||
return;
|
||||
|
||||
throw new ArtemisCoreException("Cannot add module data model that is not enabled");
|
||||
if (module.InternalDataModel.DataModelDescription == null)
|
||||
throw new ArtemisPluginFeatureException(module, "Module overrides GetDataModelDescription but returned null");
|
||||
|
||||
@@ -72,6 +71,8 @@ namespace Artemis.Core.Services
|
||||
|
||||
private void AddDataModelExpansionDataModel(BaseDataModelExpansion dataModelExpansion)
|
||||
{
|
||||
if (dataModelExpansion.InternalDataModel == null)
|
||||
throw new ArtemisCoreException("Cannot add data model expansion that is not enabled");
|
||||
if (dataModelExpansion.InternalDataModel.DataModelDescription == null)
|
||||
throw new ArtemisPluginFeatureException(dataModelExpansion, "Data model expansion overrides GetDataModelDescription but returned null");
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="operatorPluginGuid">The operator's plugin GUID</param>
|
||||
/// <param name="operatorType">The type name of the operator</param>
|
||||
BaseConditionOperator GetConditionOperator(Guid operatorPluginGuid, string operatorType);
|
||||
BaseConditionOperator? GetConditionOperator(Guid operatorPluginGuid, string operatorType);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,6 @@ namespace Artemis.Core.Services
|
||||
/// <param name="modifierTypePluginGuid">The modifier type's plugin GUID</param>
|
||||
/// <param name="modifierType">The type name of the modifier type</param>
|
||||
/// <returns></returns>
|
||||
BaseDataBindingModifierType GetModifierType(Guid modifierTypePluginGuid, string modifierType);
|
||||
BaseDataBindingModifierType? GetModifierType(Guid modifierTypePluginGuid, string modifierType);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace Artemis.Core.Services
|
||||
/// If found, returns the registered data model of type <typeparamref name="T" />
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data model to find</typeparam>
|
||||
T GetDataModel<T>() where T : DataModel;
|
||||
T? GetDataModel<T>() where T : DataModel;
|
||||
|
||||
/// <summary>
|
||||
/// If found, returns the data model of the provided plugin
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Artemis.Core.Services
|
||||
return LayerBrushStore.GetAll().Select(r => r.LayerBrushDescriptor).ToList();
|
||||
}
|
||||
|
||||
public LayerBrushDescriptor GetDefaultLayerBrush()
|
||||
public LayerBrushDescriptor? GetDefaultLayerBrush()
|
||||
{
|
||||
PluginSetting<LayerBrushReference> defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
|
||||
{
|
||||
@@ -42,6 +42,8 @@ namespace Artemis.Core.Services
|
||||
BrushType = "ColorBrush"
|
||||
});
|
||||
|
||||
defaultReference.Value.LayerBrushProviderId ??= "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba";
|
||||
defaultReference.Value.BrushType ??= "ColorBrush";
|
||||
return LayerBrushStore.Get(defaultReference.Value.LayerBrushProviderId, defaultReference.Value.BrushType)?.LayerBrushDescriptor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user