diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 58c13265f..66df68a05 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -248,8 +248,8 @@ public sealed class Layer : RenderProfileElement typeof(PropertyGroupDescriptionAttribute) )!; - LayerEntity.GeneralPropertyGroup ??= new PropertyGroupEntity {Identifier = generalAttribute.Identifier}; - LayerEntity.TransformPropertyGroup ??= new PropertyGroupEntity {Identifier = transformAttribute.Identifier}; + LayerEntity.GeneralPropertyGroup ??= new PropertyGroupEntity {Identifier = generalAttribute.Identifier!}; + LayerEntity.TransformPropertyGroup ??= new PropertyGroupEntity {Identifier = transformAttribute.Identifier!}; General.Initialize(this, null, generalAttribute, LayerEntity.GeneralPropertyGroup); Transform.Initialize(this, null, transformAttribute, LayerEntity.TransformPropertyGroup); diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs index 591dd4faa..31b4af879 100644 --- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs +++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs @@ -240,7 +240,8 @@ public abstract class LayerPropertyGroup : IDisposable foreach (LayerPropertyGroup layerPropertyGroup in LayerPropertyGroups) { layerPropertyGroup.ApplyToEntity(); - PropertyGroupEntity.PropertyGroups.Add(layerPropertyGroup.PropertyGroupEntity); + if (layerPropertyGroup.PropertyGroupEntity != null) + PropertyGroupEntity.PropertyGroups.Add(layerPropertyGroup.PropertyGroupEntity); } } diff --git a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs index 6a42aacc7..40482de47 100644 --- a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs +++ b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs @@ -46,7 +46,7 @@ public class ArtemisDevice : CorePropertyChanged InputIdentifiers = new List(); InputMappings = new Dictionary(); Categories = new HashSet(); - LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LayoutType}; + LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LAYOUT_TYPE}; RgbDevice.ColorCorrections.Clear(); RgbDevice.ColorCorrections.Add(new ScaleColorCorrection(this)); @@ -75,7 +75,7 @@ public class ArtemisDevice : CorePropertyChanged InputIdentifiers = new List(); InputMappings = new Dictionary(); Categories = new HashSet(); - LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LayoutType}; + LayoutSelection = new LayoutSelection {Type = DefaultLayoutProvider.LAYOUT_TYPE}; foreach (DeviceInputIdentifierEntity identifierEntity in DeviceEntity.InputIdentifiers) InputIdentifiers.Add(new ArtemisDeviceInputIdentifier(identifierEntity.InputProvider, identifierEntity.Identifier)); @@ -155,6 +155,9 @@ public class ArtemisDevice : CorePropertyChanged /// public HashSet Categories { get; } + /// + /// Gets the layout selection applied to this device + /// public LayoutSelection LayoutSelection { get; } /// diff --git a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs index 5304f5e37..44ddbf082 100644 --- a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs +++ b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs @@ -57,6 +57,9 @@ public class ArtemisLayout /// public LayoutCustomDeviceData LayoutCustomDeviceData { get; private set; } = null!; + /// + /// Gets a boolean indicating whether this layout is a default layout or not + /// public bool IsDefaultLayout { get; private set; } /// diff --git a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs index 3e245f9c4..e82488b46 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs @@ -65,7 +65,7 @@ public class LayerBrushDescriptor BaseLayerBrush brush = (BaseLayerBrush) Provider.Plugin.Resolve(LayerBrushType); brush.Layer = layer; brush.Descriptor = this; - brush.LayerBrushEntity = entity ?? new LayerBrushEntity {ProviderId = Provider.Id, BrushType = LayerBrushType.FullName}; + brush.LayerBrushEntity = entity ?? new LayerBrushEntity {ProviderId = Provider.Id, BrushType = LayerBrushType.FullName ?? throw new InvalidOperationException()}; brush.Initialize(); return brush; diff --git a/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs b/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs index 94cc830ba..7d300077f 100644 --- a/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs +++ b/src/Artemis.Core/Plugins/LayerEffects/Internal/BaseLayerEffect.cs @@ -231,7 +231,7 @@ public abstract class BaseLayerEffect : BreakableModel, IDisposable, IStorageMod return; LayerEffectEntity.ProviderId = Descriptor.Provider.Id; - LayerEffectEntity.EffectType = GetType().FullName; + LayerEffectEntity.EffectType = GetType().FullName ?? throw new InvalidOperationException(); BaseProperties?.ApplyToEntity(); LayerEffectEntity.PropertyGroup = BaseProperties?.PropertyGroupEntity; } diff --git a/src/Artemis.Core/Plugins/Settings/PluginSettings.cs b/src/Artemis.Core/Plugins/Settings/PluginSettings.cs index 8e795caaf..84061e48e 100644 --- a/src/Artemis.Core/Plugins/Settings/PluginSettings.cs +++ b/src/Artemis.Core/Plugins/Settings/PluginSettings.cs @@ -41,7 +41,7 @@ public class PluginSettings if (_settingEntities.ContainsKey(name)) return (PluginSetting) _settingEntities[name]; // Try to find in database - PluginSettingEntity settingEntity = _pluginRepository.GetSettingByNameAndGuid(name, Plugin.Guid); + PluginSettingEntity? settingEntity = _pluginRepository.GetSettingByNameAndGuid(name, Plugin.Guid); // If not found, create a new one if (settingEntity == null) { diff --git a/src/Artemis.Core/Providers/CustomPathLayoutProvider.cs b/src/Artemis.Core/Providers/CustomPathLayoutProvider.cs index bd2ba228b..21e932540 100644 --- a/src/Artemis.Core/Providers/CustomPathLayoutProvider.cs +++ b/src/Artemis.Core/Providers/CustomPathLayoutProvider.cs @@ -1,8 +1,14 @@ namespace Artemis.Core.Providers; +/// +/// Represents a layout provider that loads a layout from a custom path. +/// public class CustomPathLayoutProvider : ILayoutProvider { - public static string LayoutType = "CustomPath"; + /// + /// The layout type of this layout provider. + /// + public const string LAYOUT_TYPE = "CustomPath"; /// public ArtemisLayout? GetDeviceLayout(ArtemisDevice device) @@ -21,7 +27,7 @@ public class CustomPathLayoutProvider : ILayoutProvider /// public bool IsMatch(ArtemisDevice device) { - return device.LayoutSelection.Type == LayoutType; + return device.LayoutSelection.Type == LAYOUT_TYPE; } /// @@ -31,7 +37,7 @@ public class CustomPathLayoutProvider : ILayoutProvider /// The path to the custom layout. public void ConfigureDevice(ArtemisDevice device, string? path) { - device.LayoutSelection.Type = LayoutType; + device.LayoutSelection.Type = LAYOUT_TYPE; device.LayoutSelection.Parameter = path; } } \ No newline at end of file diff --git a/src/Artemis.Core/Providers/DefaultLayoutProvider.cs b/src/Artemis.Core/Providers/DefaultLayoutProvider.cs index 8c709ab27..906cd445c 100644 --- a/src/Artemis.Core/Providers/DefaultLayoutProvider.cs +++ b/src/Artemis.Core/Providers/DefaultLayoutProvider.cs @@ -1,8 +1,14 @@ namespace Artemis.Core.Providers; +/// +/// Represents a layout provider that loads a layout from the plugin and falls back to a default layout. +/// public class DefaultLayoutProvider : ILayoutProvider { - public static string LayoutType = "Default"; + /// + /// The layout type of this layout provider. + /// + public const string LAYOUT_TYPE = "Default"; /// public ArtemisLayout? GetDeviceLayout(ArtemisDevice device) @@ -26,7 +32,7 @@ public class DefaultLayoutProvider : ILayoutProvider /// public bool IsMatch(ArtemisDevice device) { - return device.LayoutSelection.Type == LayoutType; + return device.LayoutSelection.Type == LAYOUT_TYPE; } /// @@ -35,7 +41,7 @@ public class DefaultLayoutProvider : ILayoutProvider /// The device to apply the provider to. public void ConfigureDevice(ArtemisDevice device) { - device.LayoutSelection.Type = LayoutType; + device.LayoutSelection.Type = LAYOUT_TYPE; device.LayoutSelection.Parameter = null; } } \ No newline at end of file diff --git a/src/Artemis.Core/Providers/Interfaces/ILayoutProvider.cs b/src/Artemis.Core/Providers/Interfaces/ILayoutProvider.cs index 3cccfe39d..2ce2e511c 100644 --- a/src/Artemis.Core/Providers/Interfaces/ILayoutProvider.cs +++ b/src/Artemis.Core/Providers/Interfaces/ILayoutProvider.cs @@ -12,6 +12,17 @@ public interface ILayoutProvider /// The resulting layout if one was available; otherwise . ArtemisLayout? GetDeviceLayout(ArtemisDevice device); + /// + /// Applies the layout to the provided device. + /// + /// The device to apply to. + /// The layout to apply. void ApplyLayout(ArtemisDevice device, ArtemisLayout layout); + + /// + /// Determines whether the provided device is configured to use this layout provider. + /// + /// The device to check. + /// A value indicating whether the provided device is configured to use this layout provider. bool IsMatch(ArtemisDevice device); } \ No newline at end of file diff --git a/src/Artemis.Core/Providers/NoneLayoutProvider.cs b/src/Artemis.Core/Providers/NoneLayoutProvider.cs index 59c13391b..1a1c774c7 100644 --- a/src/Artemis.Core/Providers/NoneLayoutProvider.cs +++ b/src/Artemis.Core/Providers/NoneLayoutProvider.cs @@ -1,8 +1,14 @@ namespace Artemis.Core.Providers; +/// +/// Represents a layout provider that does not load a layout. +/// public class NoneLayoutProvider : ILayoutProvider { - public static string LayoutType = "None"; + /// + /// The layout type of this layout provider. + /// + public const string LAYOUT_TYPE = "None"; /// public ArtemisLayout? GetDeviceLayout(ArtemisDevice device) @@ -19,7 +25,7 @@ public class NoneLayoutProvider : ILayoutProvider /// public bool IsMatch(ArtemisDevice device) { - return device.LayoutSelection.Type == LayoutType; + return device.LayoutSelection.Type == LAYOUT_TYPE; } /// @@ -28,7 +34,7 @@ public class NoneLayoutProvider : ILayoutProvider /// The device to apply the provider to. public void ConfigureDevice(ArtemisDevice device) { - device.LayoutSelection.Type = LayoutType; + device.LayoutSelection.Type = LAYOUT_TYPE; device.LayoutSelection.Parameter = null; } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/ProcessMonitoring/ProcessMonitor.cs b/src/Artemis.Core/Services/ProcessMonitoring/ProcessMonitor.cs index 0ad901301..aa0cf8d5b 100644 --- a/src/Artemis.Core/Services/ProcessMonitoring/ProcessMonitor.cs +++ b/src/Artemis.Core/Services/ProcessMonitoring/ProcessMonitor.cs @@ -7,6 +7,9 @@ using System.Threading; namespace Artemis.Core.Services; +/// +/// Represents a monitor that efficiently keeps track of running processes. +/// public static partial class ProcessMonitor { #region Properties & Fields @@ -15,8 +18,11 @@ public static partial class ProcessMonitor private static Timer? _timer; - private static Dictionary _processes = new(); + private static readonly Dictionary _processes = new(); + /// + /// Gets an immutable array of the current processes. + /// public static ImmutableArray Processes { get @@ -25,9 +31,17 @@ public static partial class ProcessMonitor return _processes.Values.ToImmutableArray(); } } + + /// + /// Gets the date time at which the last update took place. + /// public static DateTime LastUpdate { get; private set; } private static TimeSpan _updateInterval = TimeSpan.FromSeconds(1); + + /// + /// Gets or sets the interval at which to update the list of processes. + /// public static TimeSpan UpdateInterval { get => _updateInterval; @@ -40,6 +54,9 @@ public static partial class ProcessMonitor } } + /// + /// Gets a value indicating whether the monitoring has started. + /// public static bool IsStarted { get @@ -53,7 +70,14 @@ public static partial class ProcessMonitor #region Events + /// + /// Occurs when a new process is started. + /// public static event EventHandler? ProcessStarted; + + /// + /// Occurs when a process is stopped. + /// public static event EventHandler? ProcessStopped; #endregion @@ -69,6 +93,9 @@ public static partial class ProcessMonitor #region Methods + /// + /// Starts monitoring processes. + /// public static void Start() { lock (LOCK) @@ -87,6 +114,9 @@ public static partial class ProcessMonitor } } + /// + /// Stops monitoring processes. + /// public static void Stop() { lock (LOCK) @@ -100,7 +130,7 @@ public static partial class ProcessMonitor FreeBuffer(); } } - + /// /// Returns whether the specified process is running /// @@ -111,7 +141,7 @@ public static partial class ProcessMonitor { if (!IsStarted || (processName == null && processLocation == null)) return false; - + lock (LOCK) { return _processes.Values.Any(x => IsProcessRunning(x, processName, processLocation)); @@ -130,19 +160,19 @@ public static partial class ProcessMonitor OnProcessStopped(info); } } - + private static bool IsProcessRunning(ProcessInfo info, string? processName, string? processLocation) { if (processName != null && processLocation != null) return string.Equals(info.ProcessName, processName, StringComparison.InvariantCultureIgnoreCase) && string.Equals(Path.GetDirectoryName(info.Executable), processLocation, StringComparison.InvariantCultureIgnoreCase); - + if (processName != null) return string.Equals(info.ProcessName, processName, StringComparison.InvariantCultureIgnoreCase); - + if (processLocation != null) return string.Equals(Path.GetDirectoryName(info.Executable), processLocation, StringComparison.InvariantCultureIgnoreCase); - + return false; } @@ -152,7 +182,10 @@ public static partial class ProcessMonitor { ProcessStarted?.Invoke(null, new ProcessEventArgs(processInfo)); } - catch { /* Subscribers are idiots! */ } + catch + { + /* Subscribers are idiots! */ + } } private static void OnProcessStopped(ProcessInfo processInfo) @@ -161,7 +194,10 @@ public static partial class ProcessMonitor { ProcessStopped?.Invoke(null, new ProcessEventArgs(processInfo)); } - catch { /* Subscribers are idiots! */ } + catch + { + /* Subscribers are idiots! */ + } } #endregion diff --git a/src/Artemis.Core/Services/Registration/LayerBrushService.cs b/src/Artemis.Core/Services/Registration/LayerBrushService.cs index fd12bed2c..ed9858d6d 100644 --- a/src/Artemis.Core/Services/Registration/LayerBrushService.cs +++ b/src/Artemis.Core/Services/Registration/LayerBrushService.cs @@ -42,6 +42,7 @@ internal class LayerBrushService : ILayerBrushService BrushType = "SolidBrush" }); + defaultReference.Value ??= new LayerBrushReference(); defaultReference.Value.LayerBrushProviderId ??= "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba"; defaultReference.Value.BrushType ??= "SolidBrush"; return LayerBrushStore.Get(defaultReference.Value.LayerBrushProviderId, defaultReference.Value.BrushType)?.LayerBrushDescriptor; diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index f93a4f152..f2dd26de6 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -221,7 +221,7 @@ internal class ProfileService : IProfileService return profileConfiguration.Profile; } - ProfileEntity profileEntity; + ProfileEntity? profileEntity; try { profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId); @@ -280,7 +280,7 @@ internal class ProfileService : IProfileService { DeactivateProfile(profileConfiguration); - ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId); + ProfileEntity? profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId); if (profileEntity == null) return; @@ -353,7 +353,7 @@ internal class ProfileService : IProfileService DeactivateProfile(profileConfiguration); SaveProfileCategory(profileConfiguration.Category); - ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId); + ProfileEntity? profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId); if (profileEntity != null) _profileRepository.Remove(profileEntity); diff --git a/src/Artemis.Core/Services/WebServer/Interfaces/IWebServerService.cs b/src/Artemis.Core/Services/WebServer/Interfaces/IWebServerService.cs index b950f9f49..d185d33c9 100644 --- a/src/Artemis.Core/Services/WebServer/Interfaces/IWebServerService.cs +++ b/src/Artemis.Core/Services/WebServer/Interfaces/IWebServerService.cs @@ -100,7 +100,7 @@ public interface IWebServerService : IArtemisService /// /// Removes an existing Web API controller and restarts the web server /// - /// The type of Web API controller to remove + /// The registration of the controller to remove. void RemoveController(WebApiControllerRegistration registration); /// diff --git a/src/Artemis.Storage/Artemis.Storage.csproj b/src/Artemis.Storage/Artemis.Storage.csproj index d682d5570..d7ebef960 100644 --- a/src/Artemis.Storage/Artemis.Storage.csproj +++ b/src/Artemis.Storage/Artemis.Storage.csproj @@ -1,12 +1,14 @@ - + net8.0 false x64 + enable + \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/General/QueuedActionEntity.cs b/src/Artemis.Storage/Entities/General/QueuedActionEntity.cs index 45c7e72fa..942a6501d 100644 --- a/src/Artemis.Storage/Entities/General/QueuedActionEntity.cs +++ b/src/Artemis.Storage/Entities/General/QueuedActionEntity.cs @@ -11,7 +11,7 @@ public class QueuedActionEntity } public Guid Id { get; set; } - public string Type { get; set; } + public string Type { get; set; } = string.Empty; public DateTimeOffset CreatedAt { get; set; } public Dictionary Parameters { get; set; } diff --git a/src/Artemis.Storage/Entities/General/ReleaseEntity.cs b/src/Artemis.Storage/Entities/General/ReleaseEntity.cs index b3f39fb64..f83efb6f1 100644 --- a/src/Artemis.Storage/Entities/General/ReleaseEntity.cs +++ b/src/Artemis.Storage/Entities/General/ReleaseEntity.cs @@ -6,6 +6,6 @@ public class ReleaseEntity { public Guid Id { get; set; } - public string Version { get; set; } + public string Version { get; set; } = string.Empty; public DateTimeOffset? InstalledAt { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/General/ScriptConfigurationEntity.cs b/src/Artemis.Storage/Entities/General/ScriptConfigurationEntity.cs index 73709a8a4..3bd28f252 100644 --- a/src/Artemis.Storage/Entities/General/ScriptConfigurationEntity.cs +++ b/src/Artemis.Storage/Entities/General/ScriptConfigurationEntity.cs @@ -6,7 +6,7 @@ public class ScriptConfigurationEntity { public Guid Id { get; set; } - public string Name { get; set; } - public string ScriptingProviderId { get; set; } - public string ScriptContent { get; set; } + public string Name { get; set; } = string.Empty; + public string ScriptingProviderId { get; set; } = string.Empty; + public string? ScriptContent { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Plugins/PluginEntity.cs b/src/Artemis.Storage/Entities/Plugins/PluginEntity.cs index 2be0e45e1..611200781 100644 --- a/src/Artemis.Storage/Entities/Plugins/PluginEntity.cs +++ b/src/Artemis.Storage/Entities/Plugins/PluginEntity.cs @@ -24,6 +24,6 @@ public class PluginEntity /// public class PluginFeatureEntity { - public string Type { get; set; } + public string Type { get; set; } = string.Empty; public bool IsEnabled { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Plugins/PluginSettingEntity.cs b/src/Artemis.Storage/Entities/Plugins/PluginSettingEntity.cs index 26068c503..1d604c28a 100644 --- a/src/Artemis.Storage/Entities/Plugins/PluginSettingEntity.cs +++ b/src/Artemis.Storage/Entities/Plugins/PluginSettingEntity.cs @@ -10,6 +10,6 @@ public class PluginSettingEntity public Guid Id { get; set; } public Guid PluginGuid { get; set; } - public string Name { get; set; } - public string Value { get; set; } + public string Name { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Abstract/DisplayConditionPartEntity.cs b/src/Artemis.Storage/Entities/Profile/Abstract/DisplayConditionPartEntity.cs deleted file mode 100644 index 951c09e15..000000000 --- a/src/Artemis.Storage/Entities/Profile/Abstract/DisplayConditionPartEntity.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections.Generic; - -namespace Artemis.Storage.Entities.Profile.Abstract; - -public abstract class DataModelConditionPartEntity -{ - public List Children { get; set; } -} \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Abstract/RenderElementEntity.cs b/src/Artemis.Storage/Entities/Profile/Abstract/RenderElementEntity.cs index 688b202ff..f31ca23ef 100644 --- a/src/Artemis.Storage/Entities/Profile/Abstract/RenderElementEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Abstract/RenderElementEntity.cs @@ -8,8 +8,8 @@ public abstract class RenderElementEntity public Guid Id { get; set; } public Guid ParentId { get; set; } - public List LayerEffects { get; set; } + public List LayerEffects { get; set; } = new(); - public IConditionEntity DisplayCondition { get; set; } - public TimelineEntity Timeline { get; set; } + public IConditionEntity? DisplayCondition { get; set; } + public TimelineEntity? Timeline { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/AdaptionHints/IAdaptionHintEntity.cs b/src/Artemis.Storage/Entities/Profile/AdaptionHints/IAdaptionHintEntity.cs index 03f144000..57c914786 100644 --- a/src/Artemis.Storage/Entities/Profile/AdaptionHints/IAdaptionHintEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/AdaptionHints/IAdaptionHintEntity.cs @@ -1,5 +1,3 @@ namespace Artemis.Storage.Entities.Profile.AdaptionHints; -public interface IAdaptionHintEntity -{ -} \ No newline at end of file +public interface IAdaptionHintEntity; \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/AlwaysOnConditionEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/AlwaysOnConditionEntity.cs index efb0a4763..549fde0b7 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/AlwaysOnConditionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/AlwaysOnConditionEntity.cs @@ -2,6 +2,4 @@ namespace Artemis.Storage.Entities.Profile.Conditions; -public class AlwaysOnConditionEntity : IConditionEntity -{ -} \ No newline at end of file +public class AlwaysOnConditionEntity : IConditionEntity; \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/EventConditionEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/EventConditionEntity.cs index e88f854b5..fa2af4270 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/EventConditionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/EventConditionEntity.cs @@ -8,6 +8,6 @@ public class EventConditionEntity : IConditionEntity public int TriggerMode { get; set; } public int OverlapMode { get; set; } public int ToggleOffMode { get; set; } - public DataModelPathEntity EventPath { get; set; } - public NodeScriptEntity Script { get; set; } + public DataModelPathEntity? EventPath { get; set; } + public NodeScriptEntity? Script { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/IConditionEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/IConditionEntity.cs index 206872aeb..f1f24ee14 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/IConditionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/IConditionEntity.cs @@ -1,5 +1,3 @@ namespace Artemis.Storage.Entities.Profile.Abstract; -public interface IConditionEntity -{ -} \ No newline at end of file +public interface IConditionEntity; \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/PlayOnceConditionEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/PlayOnceConditionEntity.cs index 5b365a195..8264a58f8 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/PlayOnceConditionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/PlayOnceConditionEntity.cs @@ -2,6 +2,4 @@ namespace Artemis.Storage.Entities.Profile.Conditions; -public class PlayOnceConditionEntity : IConditionEntity -{ -} \ No newline at end of file +public class PlayOnceConditionEntity : IConditionEntity; \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Conditions/StaticConditionEntity.cs b/src/Artemis.Storage/Entities/Profile/Conditions/StaticConditionEntity.cs index 0165ed33f..2aec38205 100644 --- a/src/Artemis.Storage/Entities/Profile/Conditions/StaticConditionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Conditions/StaticConditionEntity.cs @@ -7,5 +7,5 @@ public class StaticConditionEntity : IConditionEntity { public int PlayMode { get; set; } public int StopMode { get; set; } - public NodeScriptEntity Script { get; set; } + public NodeScriptEntity? Script { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs b/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs index 338f04bcf..93517b01c 100644 --- a/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs @@ -4,7 +4,6 @@ namespace Artemis.Storage.Entities.Profile.DataBindings; public class DataBindingEntity { - public string Identifier { get; set; } public bool IsEnabled { get; set; } - public NodeScriptEntity NodeScript { get; set; } + public NodeScriptEntity? NodeScript { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/DataModelPathEntity.cs b/src/Artemis.Storage/Entities/Profile/DataModelPathEntity.cs index ef585ce45..0558f87e6 100644 --- a/src/Artemis.Storage/Entities/Profile/DataModelPathEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/DataModelPathEntity.cs @@ -2,7 +2,7 @@ public class DataModelPathEntity { - public string Path { get; set; } - public string DataModelId { get; set; } - public string Type { get; set; } + public string Path { get; set; } = string.Empty; + public string? DataModelId { get; set; } + public string? Type { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/FolderEntity.cs b/src/Artemis.Storage/Entities/Profile/FolderEntity.cs index 939396b62..f47aa6bb8 100644 --- a/src/Artemis.Storage/Entities/Profile/FolderEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/FolderEntity.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using Artemis.Storage.Entities.Profile.Abstract; using LiteDB; @@ -7,18 +6,13 @@ namespace Artemis.Storage.Entities.Profile; public class FolderEntity : RenderElementEntity { - public FolderEntity() - { - LayerEffects = new List(); - } - public int Order { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public bool IsExpanded { get; set; } public bool Suspended { get; set; } [BsonRef("ProfileEntity")] - public ProfileEntity Profile { get; set; } + public ProfileEntity Profile { get; set; } = null!; public Guid ProfileId { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/KeyframeEntity.cs b/src/Artemis.Storage/Entities/Profile/KeyframeEntity.cs index 331063ac4..48cb5e220 100644 --- a/src/Artemis.Storage/Entities/Profile/KeyframeEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/KeyframeEntity.cs @@ -6,6 +6,6 @@ public class KeyframeEntity { public TimeSpan Position { get; set; } public int Timeline { get; set; } - public string Value { get; set; } + public string Value { get; set; } = string.Empty; public int EasingFunction { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/LayerBrushEntity.cs b/src/Artemis.Storage/Entities/Profile/LayerBrushEntity.cs index b539be6b7..36496ef52 100644 --- a/src/Artemis.Storage/Entities/Profile/LayerBrushEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LayerBrushEntity.cs @@ -2,8 +2,8 @@ public class LayerBrushEntity { - public string ProviderId { get; set; } - public string BrushType { get; set; } + public string ProviderId { get; set; } = string.Empty; + public string BrushType { get; set; } = string.Empty; - public PropertyGroupEntity PropertyGroup { get; set; } + public PropertyGroupEntity? PropertyGroup { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/LayerEffectEntity.cs b/src/Artemis.Storage/Entities/Profile/LayerEffectEntity.cs index 0e0ba6033..2ee9376ea 100644 --- a/src/Artemis.Storage/Entities/Profile/LayerEffectEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LayerEffectEntity.cs @@ -2,11 +2,11 @@ public class LayerEffectEntity { - public string ProviderId { get; set; } - public string EffectType { get; set; } - public string Name { get; set; } + public string ProviderId { get; set; } = string.Empty; + public string EffectType { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; public bool HasBeenRenamed { get; set; } public int Order { get; set; } - public PropertyGroupEntity PropertyGroup { get; set; } + public PropertyGroupEntity? PropertyGroup { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs index 30fc9ca1b..521550b34 100644 --- a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs @@ -12,22 +12,21 @@ public class LayerEntity : RenderElementEntity { Leds = new List(); AdaptionHints = new List(); - LayerEffects = new List(); } public int Order { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public bool Suspended { get; set; } public List Leds { get; set; } public List AdaptionHints { get; set; } - public PropertyGroupEntity GeneralPropertyGroup { get; set; } - public PropertyGroupEntity TransformPropertyGroup { get; set; } - public LayerBrushEntity LayerBrush { get; set; } + public PropertyGroupEntity? GeneralPropertyGroup { get; set; } + public PropertyGroupEntity? TransformPropertyGroup { get; set; } + public LayerBrushEntity? LayerBrush { get; set; } [BsonRef("ProfileEntity")] - public ProfileEntity Profile { get; set; } + public ProfileEntity Profile { get; set; } = null!; public Guid ProfileId { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/LedEntity.cs b/src/Artemis.Storage/Entities/Profile/LedEntity.cs index be4536471..da89f9d7d 100644 --- a/src/Artemis.Storage/Entities/Profile/LedEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LedEntity.cs @@ -5,8 +5,8 @@ namespace Artemis.Storage.Entities.Profile; public class LedEntity { - public string LedName { get; set; } - public string DeviceIdentifier { get; set; } + public string LedName { get; set; } = string.Empty; + public string DeviceIdentifier { get; set; } = string.Empty; public int? PhysicalLayout { get; set; } @@ -14,7 +14,7 @@ public class LedEntity private sealed class LedEntityEqualityComparer : IEqualityComparer { - public bool Equals(LedEntity x, LedEntity y) + public bool Equals(LedEntity? x, LedEntity? y) { if (ReferenceEquals(x, y)) return true; diff --git a/src/Artemis.Storage/Entities/Profile/Nodes/NodeConnectionEntity.cs b/src/Artemis.Storage/Entities/Profile/Nodes/NodeConnectionEntity.cs index b85678d53..df21b1535 100644 --- a/src/Artemis.Storage/Entities/Profile/Nodes/NodeConnectionEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Nodes/NodeConnectionEntity.cs @@ -20,12 +20,12 @@ public class NodeConnectionEntity TargetPinId = nodeConnectionEntity.TargetPinId; } - public string SourceType { get; set; } + public string SourceType { get; set; } = string.Empty; public Guid SourceNode { get; set; } public Guid TargetNode { get; set; } public int SourcePinCollectionId { get; set; } public int SourcePinId { get; set; } - public string TargetType { get; set; } + public string TargetType { get; set; } = string.Empty; public int TargetPinCollectionId { get; set; } public int TargetPinId { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Nodes/NodeEntity.cs b/src/Artemis.Storage/Entities/Profile/Nodes/NodeEntity.cs index 5683e5c0f..234d3c7a7 100644 --- a/src/Artemis.Storage/Entities/Profile/Nodes/NodeEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Nodes/NodeEntity.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; @@ -28,15 +28,15 @@ public class NodeEntity } public Guid Id { get; set; } - public string Type { get; set; } + public string Type { get; set; } = string.Empty; public Guid PluginId { get; set; } - public string Name { get; set; } - public string Description { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; public bool IsExitNode { get; set; } public double X { get; set; } public double Y { get; set; } - public string Storage { get; set; } + public string Storage { get; set; } = string.Empty; public List PinCollections { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/Nodes/NodeScriptEntity.cs b/src/Artemis.Storage/Entities/Profile/Nodes/NodeScriptEntity.cs index 0ca825e70..ac53e8494 100644 --- a/src/Artemis.Storage/Entities/Profile/Nodes/NodeScriptEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/Nodes/NodeScriptEntity.cs @@ -10,8 +10,8 @@ public class NodeScriptEntity Connections = new List(); } - public string Name { get; set; } - public string Description { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; public List Nodes { get; set; } public List Connections { get; set; } diff --git a/src/Artemis.Storage/Entities/Profile/ProfileCategoryEntity.cs b/src/Artemis.Storage/Entities/Profile/ProfileCategoryEntity.cs index 8dfebeb96..126845b38 100644 --- a/src/Artemis.Storage/Entities/Profile/ProfileCategoryEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/ProfileCategoryEntity.cs @@ -7,7 +7,7 @@ public class ProfileCategoryEntity { public Guid Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } = string.Empty; public bool IsCollapsed { get; set; } public bool IsSuspended { get; set; } public int Order { get; set; } diff --git a/src/Artemis.Storage/Entities/Profile/ProfileConfigurationEntity.cs b/src/Artemis.Storage/Entities/Profile/ProfileConfigurationEntity.cs index 276b6ec8d..17f94580b 100644 --- a/src/Artemis.Storage/Entities/Profile/ProfileConfigurationEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/ProfileConfigurationEntity.cs @@ -5,8 +5,8 @@ namespace Artemis.Storage.Entities.Profile; public class ProfileConfigurationEntity { - public string Name { get; set; } - public string MaterialIcon { get; set; } + public string Name { get; set; } = string.Empty; + public string? MaterialIcon { get; set; } public Guid FileIconId { get; set; } public int IconType { get; set; } public bool IconFill { get; set; } @@ -14,13 +14,13 @@ public class ProfileConfigurationEntity public bool IsSuspended { get; set; } public int ActivationBehaviour { get; set; } - public NodeScriptEntity ActivationCondition { get; set; } + public NodeScriptEntity? ActivationCondition { get; set; } public int HotkeyMode { get; set; } - public ProfileConfigurationHotkeyEntity EnableHotkey { get; set; } - public ProfileConfigurationHotkeyEntity DisableHotkey { get; set; } + public ProfileConfigurationHotkeyEntity? EnableHotkey { get; set; } + public ProfileConfigurationHotkeyEntity? DisableHotkey { get; set; } - public string ModuleId { get; set; } + public string? ModuleId { get; set; } public Guid ProfileCategoryId { get; set; } public Guid ProfileId { get; set; } diff --git a/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs b/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs index da5bbb903..ba4e57720 100644 --- a/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs @@ -16,7 +16,7 @@ public class ProfileEntity public Guid Id { get; set; } - public string Name { get; set; } + public string Name { get; set; } = string.Empty; public bool IsFreshImport { get; set; } public List Folders { get; set; } @@ -28,7 +28,7 @@ public class ProfileEntity Guid oldGuid = Id; Id = guid; - FolderEntity rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid); + FolderEntity? rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid); if (rootFolder != null) rootFolder.ParentId = Id; } diff --git a/src/Artemis.Storage/Entities/Profile/PropertyEntity.cs b/src/Artemis.Storage/Entities/Profile/PropertyEntity.cs index 21036efcc..3b4f8e833 100644 --- a/src/Artemis.Storage/Entities/Profile/PropertyEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/PropertyEntity.cs @@ -5,10 +5,10 @@ namespace Artemis.Storage.Entities.Profile; public class PropertyEntity { - public string Identifier { get; set; } - public string Value { get; set; } + public string Identifier { get; set; } = string.Empty; + public string Value { get; set; } = string.Empty; public bool KeyframesEnabled { get; set; } - public DataBindingEntity DataBinding { get; set; } + public DataBindingEntity? DataBinding { get; set; } public List KeyframeEntities { get; set; } = new(); } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Profile/PropertyGroupEntity.cs b/src/Artemis.Storage/Entities/Profile/PropertyGroupEntity.cs index 3f4825782..e01047ee3 100644 --- a/src/Artemis.Storage/Entities/Profile/PropertyGroupEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/PropertyGroupEntity.cs @@ -4,7 +4,7 @@ namespace Artemis.Storage.Entities.Profile; public class PropertyGroupEntity { - public string Identifier { get; set; } + public string Identifier { get; set; } = string.Empty; public List Properties { get; set; } = new(); public List PropertyGroups { get; set; } = new(); } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs b/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs index b19e38c03..5075131c2 100644 --- a/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs +++ b/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs @@ -11,8 +11,8 @@ public class DeviceEntity Categories = new List(); } - public string Id { get; set; } - public string DeviceProvider { get; set; } + public string Id { get; set; } = string.Empty; + public string DeviceProvider { get; set; } = string.Empty; public float X { get; set; } public float Y { get; set; } public float Rotation { get; set; } @@ -24,9 +24,9 @@ public class DeviceEntity public bool IsEnabled { get; set; } public int PhysicalLayout { get; set; } - public string LogicalLayout { get; set; } - public string LayoutType { get; set; } - public string LayoutParameter { get; set; } + public string? LogicalLayout { get; set; } + public string? LayoutType { get; set; } + public string? LayoutParameter { get; set; } public List InputIdentifiers { get; set; } public List InputMappings { get; set; } @@ -41,6 +41,6 @@ public class InputMappingEntity public class DeviceInputIdentifierEntity { - public string InputProvider { get; set; } - public object Identifier { get; set; } + public string InputProvider { get; set; } = string.Empty; + public object Identifier { get; set; } = string.Empty; } \ No newline at end of file diff --git a/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs b/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs index e2acf7922..4be84d9e8 100644 --- a/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs +++ b/src/Artemis.Storage/Entities/Workshop/EntryEntity.cs @@ -10,13 +10,12 @@ public class EntryEntity public long EntryId { get; set; } public int EntryType { get; set; } - public string Author { get; set; } + public string Author { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; - public string Summary { get; set; } = string.Empty; public long ReleaseId { get; set; } - public string ReleaseVersion { get; set; } + public string ReleaseVersion { get; set; } = string.Empty; public DateTimeOffset InstalledAt { get; set; } - public Dictionary Metadata { get; set; } + public Dictionary? Metadata { get; set; } } \ No newline at end of file diff --git a/src/Artemis.Storage/Migrations/IProfileMigration.cs b/src/Artemis.Storage/Migrations/IProfileMigration.cs new file mode 100644 index 000000000..d48cab32b --- /dev/null +++ b/src/Artemis.Storage/Migrations/IProfileMigration.cs @@ -0,0 +1,11 @@ +using LiteDB; +using Newtonsoft.Json.Linq; + +namespace Artemis.Storage.Migrations; + +internal interface IProfileMigration +{ + int Version { get; } + void Migrate(JObject profileJson); + void Migrate(BsonDocument profileBson); +} \ No newline at end of file diff --git a/src/Artemis.Storage/Migrations/Interfaces/IStorageMigration.cs b/src/Artemis.Storage/Migrations/IStorageMigration.cs similarity index 100% rename from src/Artemis.Storage/Migrations/Interfaces/IStorageMigration.cs rename to src/Artemis.Storage/Migrations/IStorageMigration.cs diff --git a/src/Artemis.Storage/Migrations/Profile/M0001NodeProviders.cs b/src/Artemis.Storage/Migrations/Profile/M0001NodeProviders.cs new file mode 100644 index 000000000..9e8f62f1f --- /dev/null +++ b/src/Artemis.Storage/Migrations/Profile/M0001NodeProviders.cs @@ -0,0 +1,97 @@ +using LiteDB; +using Newtonsoft.Json.Linq; + +namespace Artemis.Storage.Migrations.Profile; + +/// +/// Migrates nodes to be provider-based. +/// This requires giving them a ProviderId and updating the their namespaces to match the namespace of the new plugin. +/// +internal class M0001NodeProviders : IProfileMigration +{ + /// + public int Version => 1; + + /// + public void Migrate(JObject profileJson) + { + JArray? folders = (JArray?) profileJson["Folders"]?["$values"]; + JArray? layers = (JArray?) profileJson["Layers"]?["$values"]; + + if (folders != null) + { + foreach (JToken folder in folders) + { + MigrateProfileElement(folder); + } + } + + if (layers != null) + { + foreach (JToken layer in layers) + { + MigrateProfileElement(layer); + MigratePropertyGroup(layer["GeneralPropertyGroup"]); + MigratePropertyGroup(layer["TransformPropertyGroup"]); + MigratePropertyGroup(layer["LayerBrush"]?["PropertyGroup"]); + } + } + } + + /// + public void Migrate(BsonDocument profileBson) + { + throw new System.NotImplementedException(); + } + + private void MigrateProfileElement(JToken profileElement) + { + JArray? layerEffects = (JArray?) profileElement["LayerEffects"]?["$values"]; + if (layerEffects != null) + { + foreach (JToken layerEffect in layerEffects) + MigratePropertyGroup(layerEffect["PropertyGroup"]); + } + + JToken? displayCondition = profileElement["DisplayCondition"]; + if (displayCondition != null) + MigrateNodeScript(displayCondition["Script"]); + } + + private void MigratePropertyGroup(JToken? propertyGroup) + { + if (propertyGroup == null || !propertyGroup.HasValues) + return; + + JArray? properties = (JArray?) propertyGroup["Properties"]?["$values"]; + JArray? propertyGroups = (JArray?) propertyGroup["PropertyGroups"]?["$values"]; + + if (properties != null) + { + foreach (JToken property in properties) + MigrateNodeScript(property["DataBinding"]?["NodeScript"]); + } + + if (propertyGroups != null) + { + foreach (JToken childPropertyGroup in propertyGroups) + MigratePropertyGroup(childPropertyGroup); + } + } + + private void MigrateNodeScript(JToken? nodeScript) + { + if (nodeScript == null || !nodeScript.HasValues) + return; + + JArray? nodes = (JArray?) nodeScript["Nodes"]?["$values"]; + if (nodes == null) + return; + + foreach (JToken node in nodes) + { + node["Type"] = node["Type"]?.Value()?.Replace("Artemis.VisualScripting.Nodes", "Artemis.Plugins.Nodes.General.Nodes"); + node["ProviderId"] = "Artemis.Plugins.Nodes.General.GeneralNodesProvider-d9e1ee78"; + } + } +} \ No newline at end of file diff --git a/src/Artemis.Storage/Migrations/M0020AvaloniaReset.cs b/src/Artemis.Storage/Migrations/Storage/M0020AvaloniaReset.cs similarity index 100% rename from src/Artemis.Storage/Migrations/M0020AvaloniaReset.cs rename to src/Artemis.Storage/Migrations/Storage/M0020AvaloniaReset.cs diff --git a/src/Artemis.Storage/Migrations/M0021GradientNodes.cs b/src/Artemis.Storage/Migrations/Storage/M0021GradientNodes.cs similarity index 87% rename from src/Artemis.Storage/Migrations/M0021GradientNodes.cs rename to src/Artemis.Storage/Migrations/Storage/M0021GradientNodes.cs index dba1e8956..a6ebcac3e 100644 --- a/src/Artemis.Storage/Migrations/M0021GradientNodes.cs +++ b/src/Artemis.Storage/Migrations/Storage/M0021GradientNodes.cs @@ -12,9 +12,9 @@ public class M0021GradientNodes : IStorageMigration { private void MigrateDataBinding(PropertyEntity property) { - NodeScriptEntity script = property.DataBinding.NodeScript; - NodeEntity exitNode = script.Nodes.FirstOrDefault(s => s.IsExitNode); - if (exitNode == null) + NodeScriptEntity? script = property.DataBinding?.NodeScript; + NodeEntity? exitNode = script?.Nodes.FirstOrDefault(s => s.IsExitNode); + if (script == null || exitNode == null) return; // Create a new node at the same position of the exit node @@ -59,8 +59,11 @@ public class M0021GradientNodes : IStorageMigration exitNode.Y += 30; } - private void MigrateDataBinding(PropertyGroupEntity propertyGroup) + private void MigrateDataBinding(PropertyGroupEntity? propertyGroup) { + if (propertyGroup == null) + return; + foreach (PropertyGroupEntity propertyGroupPropertyGroup in propertyGroup.PropertyGroups) MigrateDataBinding(propertyGroupPropertyGroup); @@ -80,7 +83,7 @@ public class M0021GradientNodes : IStorageMigration foreach (ProfileEntity profileEntity in profiles) { foreach (LayerEntity layer in profileEntity.Layers.Where(le => le.LayerBrush != null)) - MigrateDataBinding(layer.LayerBrush.PropertyGroup); + MigrateDataBinding(layer.LayerBrush?.PropertyGroup); repository.Update(profileEntity); } diff --git a/src/Artemis.Storage/Migrations/M0022TransitionNodes.cs b/src/Artemis.Storage/Migrations/Storage/M0022TransitionNodes.cs similarity index 89% rename from src/Artemis.Storage/Migrations/M0022TransitionNodes.cs rename to src/Artemis.Storage/Migrations/Storage/M0022TransitionNodes.cs index 3258a6d10..6256c097d 100644 --- a/src/Artemis.Storage/Migrations/M0022TransitionNodes.cs +++ b/src/Artemis.Storage/Migrations/Storage/M0022TransitionNodes.cs @@ -10,7 +10,7 @@ namespace Artemis.Storage.Migrations; public class M0022TransitionNodes : IStorageMigration { - private void MigrateNodeScript(NodeScriptEntity nodeScript) + private void MigrateNodeScript(NodeScriptEntity? nodeScript) { if (nodeScript == null) return; @@ -28,7 +28,7 @@ public class M0022TransitionNodes : IStorageMigration } } - private void MigratePropertyGroup(PropertyGroupEntity propertyGroup) + private void MigratePropertyGroup(PropertyGroupEntity? propertyGroup) { if (propertyGroup == null) return; @@ -39,7 +39,7 @@ public class M0022TransitionNodes : IStorageMigration MigrateNodeScript(property.DataBinding?.NodeScript); } - private void MigrateDisplayCondition(IConditionEntity conditionEntity) + private void MigrateDisplayCondition(IConditionEntity? conditionEntity) { if (conditionEntity is EventConditionEntity eventConditionEntity) MigrateNodeScript(eventConditionEntity.Script); @@ -70,14 +70,14 @@ public class M0022TransitionNodes : IStorageMigration MigratePropertyGroup(layer.GeneralPropertyGroup); MigratePropertyGroup(layer.TransformPropertyGroup); foreach (LayerEffectEntity layerEffectEntity in layer.LayerEffects) - MigratePropertyGroup(layerEffectEntity?.PropertyGroup); + MigratePropertyGroup(layerEffectEntity.PropertyGroup); MigrateDisplayCondition(layer.DisplayCondition); } foreach (FolderEntity folder in profileEntity.Folders) { foreach (LayerEffectEntity folderLayerEffect in folder.LayerEffects) - MigratePropertyGroup(folderLayerEffect?.PropertyGroup); + MigratePropertyGroup(folderLayerEffect.PropertyGroup); MigrateDisplayCondition(folder.DisplayCondition); } diff --git a/src/Artemis.Storage/Migrations/M0023LayoutProviders.cs b/src/Artemis.Storage/Migrations/Storage/M0023LayoutProviders.cs similarity index 100% rename from src/Artemis.Storage/Migrations/M0023LayoutProviders.cs rename to src/Artemis.Storage/Migrations/Storage/M0023LayoutProviders.cs diff --git a/src/Artemis.Storage/Repositories/DeviceRepository.cs b/src/Artemis.Storage/Repositories/DeviceRepository.cs index 722d85626..47a947333 100644 --- a/src/Artemis.Storage/Repositories/DeviceRepository.cs +++ b/src/Artemis.Storage/Repositories/DeviceRepository.cs @@ -25,7 +25,7 @@ internal class DeviceRepository : IDeviceRepository _repository.Delete(deviceEntity.Id); } - public DeviceEntity Get(string id) + public DeviceEntity? Get(string id) { return _repository.FirstOrDefault(s => s.Id == id); } diff --git a/src/Artemis.Storage/Repositories/EntryRepository.cs b/src/Artemis.Storage/Repositories/EntryRepository.cs index 61d3da672..81775f967 100644 --- a/src/Artemis.Storage/Repositories/EntryRepository.cs +++ b/src/Artemis.Storage/Repositories/EntryRepository.cs @@ -27,12 +27,12 @@ internal class EntryRepository : IEntryRepository _repository.Delete(entryEntity.Id); } - public EntryEntity Get(Guid id) + public EntryEntity? Get(Guid id) { return _repository.FirstOrDefault(s => s.Id == id); } - public EntryEntity GetByEntryId(long entryId) + public EntryEntity? GetByEntryId(long entryId) { return _repository.FirstOrDefault(s => s.EntryId == entryId); } diff --git a/src/Artemis.Storage/Repositories/Interfaces/IDeviceRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IDeviceRepository.cs index 1cfa237f5..50fd1df86 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IDeviceRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IDeviceRepository.cs @@ -7,7 +7,7 @@ public interface IDeviceRepository : IRepository { void Add(DeviceEntity deviceEntity); void Remove(DeviceEntity deviceEntity); - DeviceEntity Get(string id); + DeviceEntity? Get(string id); List GetAll(); void Save(DeviceEntity deviceEntity); void Save(IEnumerable deviceEntities); diff --git a/src/Artemis.Storage/Repositories/Interfaces/IEntryRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IEntryRepository.cs index 1e9ecd1c5..59d610f95 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IEntryRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IEntryRepository.cs @@ -8,8 +8,8 @@ public interface IEntryRepository : IRepository { void Add(EntryEntity entryEntity); void Remove(EntryEntity entryEntity); - EntryEntity Get(Guid id); - EntryEntity GetByEntryId(long entryId); + EntryEntity? Get(Guid id); + EntryEntity? GetByEntryId(long entryId); List GetAll(); void Save(EntryEntity entryEntity); void Save(IEnumerable entryEntities); diff --git a/src/Artemis.Storage/Repositories/Interfaces/IPluginRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IPluginRepository.cs index 12a9c797b..c180ee33f 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IPluginRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IPluginRepository.cs @@ -6,12 +6,12 @@ namespace Artemis.Storage.Repositories.Interfaces; public interface IPluginRepository : IRepository { void AddPlugin(PluginEntity pluginEntity); - PluginEntity GetPluginByGuid(Guid pluginGuid); + PluginEntity? GetPluginByGuid(Guid pluginGuid); void SavePlugin(PluginEntity pluginEntity); void AddSetting(PluginSettingEntity pluginSettingEntity); - PluginSettingEntity GetSettingByGuid(Guid pluginGuid); - PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid); + PluginSettingEntity? GetSettingByGuid(Guid pluginGuid); + PluginSettingEntity? GetSettingByNameAndGuid(string name, Guid pluginGuid); void SaveSetting(PluginSettingEntity pluginSettingEntity); void RemoveSettings(Guid pluginGuid); } \ No newline at end of file diff --git a/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs index bdb1b93cd..878040e2c 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IProfileCategoryRepository.cs @@ -10,8 +10,8 @@ public interface IProfileCategoryRepository : IRepository void Add(ProfileCategoryEntity profileCategoryEntity); void Remove(ProfileCategoryEntity profileCategoryEntity); List GetAll(); - ProfileCategoryEntity Get(Guid id); - Stream GetProfileIconStream(Guid id); + ProfileCategoryEntity? Get(Guid id); + Stream? GetProfileIconStream(Guid id); void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream); ProfileCategoryEntity IsUnique(string name, Guid? id); void Save(ProfileCategoryEntity profileCategoryEntity); diff --git a/src/Artemis.Storage/Repositories/Interfaces/IProfileRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IProfileRepository.cs index 155bef645..8430b82c4 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IProfileRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IProfileRepository.cs @@ -9,6 +9,6 @@ public interface IProfileRepository : IRepository void Add(ProfileEntity profileEntity); void Remove(ProfileEntity profileEntity); List GetAll(); - ProfileEntity Get(Guid id); + ProfileEntity? Get(Guid id); void Save(ProfileEntity profileEntity); } \ No newline at end of file diff --git a/src/Artemis.Storage/Repositories/Interfaces/IRepository.cs b/src/Artemis.Storage/Repositories/Interfaces/IRepository.cs index 3220cae2e..cd3328434 100644 --- a/src/Artemis.Storage/Repositories/Interfaces/IRepository.cs +++ b/src/Artemis.Storage/Repositories/Interfaces/IRepository.cs @@ -1,5 +1,3 @@ namespace Artemis.Storage.Repositories.Interfaces; -public interface IRepository -{ -} \ No newline at end of file +public interface IRepository; \ No newline at end of file diff --git a/src/Artemis.Storage/Repositories/PluginRepository.cs b/src/Artemis.Storage/Repositories/PluginRepository.cs index 6d659af47..9c278b607 100644 --- a/src/Artemis.Storage/Repositories/PluginRepository.cs +++ b/src/Artemis.Storage/Repositories/PluginRepository.cs @@ -21,7 +21,7 @@ internal class PluginRepository : IPluginRepository _repository.Insert(pluginEntity); } - public PluginEntity GetPluginByGuid(Guid pluginGuid) + public PluginEntity? GetPluginByGuid(Guid pluginGuid) { return _repository.FirstOrDefault(p => p.Id == pluginGuid); } @@ -37,12 +37,12 @@ internal class PluginRepository : IPluginRepository _repository.Insert(pluginSettingEntity); } - public PluginSettingEntity GetSettingByGuid(Guid pluginGuid) + public PluginSettingEntity? GetSettingByGuid(Guid pluginGuid) { return _repository.FirstOrDefault(p => p.PluginGuid == pluginGuid); } - public PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid) + public PluginSettingEntity? GetSettingByNameAndGuid(string name, Guid pluginGuid) { return _repository.FirstOrDefault(p => p.Name == name && p.PluginGuid == pluginGuid); } diff --git a/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs b/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs index 71517929f..8e1f44ecf 100644 --- a/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs +++ b/src/Artemis.Storage/Repositories/ProfileCategoryRepository.cs @@ -34,7 +34,7 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository return _repository.Query().ToList(); } - public ProfileCategoryEntity Get(Guid id) + public ProfileCategoryEntity? Get(Guid id) { return _repository.FirstOrDefault(p => p.Id == id); } @@ -52,7 +52,7 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository _repository.Upsert(profileCategoryEntity); } - public Stream GetProfileIconStream(Guid id) + public Stream? GetProfileIconStream(Guid id) { if (!_profileIcons.Exists(id)) return null; diff --git a/src/Artemis.Storage/Repositories/ProfileRepository.cs b/src/Artemis.Storage/Repositories/ProfileRepository.cs index a890f2ee0..738099a32 100644 --- a/src/Artemis.Storage/Repositories/ProfileRepository.cs +++ b/src/Artemis.Storage/Repositories/ProfileRepository.cs @@ -31,7 +31,7 @@ internal class ProfileRepository : IProfileRepository return _repository.Query().ToList(); } - public ProfileEntity Get(Guid id) + public ProfileEntity? Get(Guid id) { return _repository.FirstOrDefault(p => p.Id == id); }