From 089cada426e597204b7322cfa9effd5637b0a8ed Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 7 Feb 2016 10:06:07 +0100 Subject: [PATCH] Refactoring --- Brushes/AbstractBrush.cs | 4 +++- Brushes/IBrush.cs | 2 ++ Brushes/LinearGradientBrush.cs | 1 + Brushes/RadialGradientBrush.cs | 1 + Brushes/RandomColorBrush.cs | 4 +++- Devices/Generic/AbstractCueDevice.cs | 5 ++++- Devices/Headset/CorsairHeadset.cs | 1 + Devices/ICueDevice.cs | 5 ++++- Devices/IDeviceInfo.cs | 5 ++++- Devices/Keyboard/Extensions/KeyGroupExtension.cs | 1 + Devices/Keyboard/Keys/IKeyGroup.cs | 5 ++++- Devices/Keyboard/Keys/ListKeyGroup.cs | 1 + Devices/Keyboard/Keys/RectangleKeyGroup.cs | 1 + Devices/Mouse/CorsairMouse.cs | 1 - Effects/FlashEffect.cs | 1 + Effects/IEffect.cs | 5 ++++- Gradients/LinearGradient.cs | 4 +++- Profiles/CueProfile.cs | 14 +++++++++----- Profiles/CueProfileDevice.cs | 3 ++- Profiles/CueProfileMode.cs | 3 ++- Profiles/CueProfiles.cs | 10 +++++++--- 21 files changed, 58 insertions(+), 19 deletions(-) diff --git a/Brushes/AbstractBrush.cs b/Brushes/AbstractBrush.cs index 56d78ac..5160433 100644 --- a/Brushes/AbstractBrush.cs +++ b/Brushes/AbstractBrush.cs @@ -1,4 +1,6 @@ -using System.Drawing; +// ReSharper disable VirtualMemberNeverOverriden.Global + +using System.Drawing; using CUE.NET.Helper; namespace CUE.NET.Brushes diff --git a/Brushes/IBrush.cs b/Brushes/IBrush.cs index f441aca..54558af 100644 --- a/Brushes/IBrush.cs +++ b/Brushes/IBrush.cs @@ -1,3 +1,5 @@ +// ReSharper disable UnusedMemberInSuper.Global + using System.Drawing; namespace CUE.NET.Brushes diff --git a/Brushes/LinearGradientBrush.cs b/Brushes/LinearGradientBrush.cs index e3a851d..672cc2d 100644 --- a/Brushes/LinearGradientBrush.cs +++ b/Brushes/LinearGradientBrush.cs @@ -2,6 +2,7 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable ReturnTypeCanBeEnumerable.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable UnusedMember.Global using System.Drawing; using CUE.NET.Gradients; diff --git a/Brushes/RadialGradientBrush.cs b/Brushes/RadialGradientBrush.cs index d3b20b7..0b97af3 100644 --- a/Brushes/RadialGradientBrush.cs +++ b/Brushes/RadialGradientBrush.cs @@ -1,5 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable UnusedMember.Global using System; using System.Drawing; diff --git a/Brushes/RandomColorBrush.cs b/Brushes/RandomColorBrush.cs index 6a4c184..5037854 100644 --- a/Brushes/RandomColorBrush.cs +++ b/Brushes/RandomColorBrush.cs @@ -1,4 +1,6 @@ -using System; +// ReSharper disable UnusedMember.Global + +using System; using System.Drawing; using CUE.NET.Helper; diff --git a/Devices/Generic/AbstractCueDevice.cs b/Devices/Generic/AbstractCueDevice.cs index f58b846..7d3ce60 100644 --- a/Devices/Generic/AbstractCueDevice.cs +++ b/Devices/Generic/AbstractCueDevice.cs @@ -1,4 +1,7 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMethodReturnValue.Global + +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; diff --git a/Devices/Headset/CorsairHeadset.cs b/Devices/Headset/CorsairHeadset.cs index 5e3eac0..b674634 100644 --- a/Devices/Headset/CorsairHeadset.cs +++ b/Devices/Headset/CorsairHeadset.cs @@ -1,5 +1,6 @@ // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global using System.Collections; using System.Collections.Generic; diff --git a/Devices/ICueDevice.cs b/Devices/ICueDevice.cs index 2ad8a14..fc6a763 100644 --- a/Devices/ICueDevice.cs +++ b/Devices/ICueDevice.cs @@ -1,4 +1,7 @@ -using CUE.NET.Devices.Generic; +// ReSharper disable UnusedMemberInSuper.Global +// ReSharper disable UnusedMember.Global + +using CUE.NET.Devices.Generic; using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Devices diff --git a/Devices/IDeviceInfo.cs b/Devices/IDeviceInfo.cs index 4034ae8..6cadcf1 100644 --- a/Devices/IDeviceInfo.cs +++ b/Devices/IDeviceInfo.cs @@ -1,4 +1,7 @@ -using CUE.NET.Devices.Generic.Enums; +// ReSharper disable UnusedMemberInSuper.Global +// ReSharper disable UnusedMember.Global + +using CUE.NET.Devices.Generic.Enums; namespace CUE.NET.Devices { diff --git a/Devices/Keyboard/Extensions/KeyGroupExtension.cs b/Devices/Keyboard/Extensions/KeyGroupExtension.cs index e1f5976..629974b 100644 --- a/Devices/Keyboard/Extensions/KeyGroupExtension.cs +++ b/Devices/Keyboard/Extensions/KeyGroupExtension.cs @@ -1,4 +1,5 @@ // ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global using System.Linq; using CUE.NET.Devices.Keyboard.Enums; diff --git a/Devices/Keyboard/Keys/IKeyGroup.cs b/Devices/Keyboard/Keys/IKeyGroup.cs index 96ab7cf..58891b2 100644 --- a/Devices/Keyboard/Keys/IKeyGroup.cs +++ b/Devices/Keyboard/Keys/IKeyGroup.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// ReSharper disable UnusedMemberInSuper.Global +// ReSharper disable UnusedMember.Global + +using System.Collections.Generic; using CUE.NET.Brushes; using CUE.NET.Devices.Generic; diff --git a/Devices/Keyboard/Keys/ListKeyGroup.cs b/Devices/Keyboard/Keys/ListKeyGroup.cs index bafae08..7fc5b84 100644 --- a/Devices/Keyboard/Keys/ListKeyGroup.cs +++ b/Devices/Keyboard/Keys/ListKeyGroup.cs @@ -1,4 +1,5 @@ // ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global using System.Collections.Generic; using CUE.NET.Devices.Keyboard.Enums; diff --git a/Devices/Keyboard/Keys/RectangleKeyGroup.cs b/Devices/Keyboard/Keys/RectangleKeyGroup.cs index 2d187dd..4185a78 100644 --- a/Devices/Keyboard/Keys/RectangleKeyGroup.cs +++ b/Devices/Keyboard/Keys/RectangleKeyGroup.cs @@ -1,5 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable UnusedMember.Global using System.Collections.Generic; using System.Drawing; diff --git a/Devices/Mouse/CorsairMouse.cs b/Devices/Mouse/CorsairMouse.cs index 8ff3888..1b181c3 100644 --- a/Devices/Mouse/CorsairMouse.cs +++ b/Devices/Mouse/CorsairMouse.cs @@ -2,7 +2,6 @@ // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedMember.Global -using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/Effects/FlashEffect.cs b/Effects/FlashEffect.cs index 7228bd6..d026cd0 100644 --- a/Effects/FlashEffect.cs +++ b/Effects/FlashEffect.cs @@ -1,5 +1,6 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable UnusedMember.Global using System; using System.Drawing; diff --git a/Effects/IEffect.cs b/Effects/IEffect.cs index 6e9ce35..4cce82c 100644 --- a/Effects/IEffect.cs +++ b/Effects/IEffect.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// ReSharper disable UnusedMember.Global +// ReSharper disable UnusedMemberInSuper.Global + +using System.Collections.Generic; using CUE.NET.Brushes; using CUE.NET.Devices.Generic; diff --git a/Gradients/LinearGradient.cs b/Gradients/LinearGradient.cs index f3ffd7a..5ac8b21 100644 --- a/Gradients/LinearGradient.cs +++ b/Gradients/LinearGradient.cs @@ -1,4 +1,6 @@ -using System.Drawing; +// ReSharper disable UnusedMember.Global + +using System.Drawing; using System.Linq; namespace CUE.NET.Gradients diff --git a/Profiles/CueProfile.cs b/Profiles/CueProfile.cs index c69b5cf..e9e40ed 100644 --- a/Profiles/CueProfile.cs +++ b/Profiles/CueProfile.cs @@ -1,4 +1,8 @@ -using System.Collections.Generic; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +// ReSharper disable UnusedMember.Global + +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Linq; @@ -10,17 +14,16 @@ namespace CUE.NET.Profiles { #region Properties & Fields + private Dictionary _devices; + public string Id { get; } public string Name { get; } - private Dictionary _devices; - public IEnumerable Modes { get { string device = _devices.Keys.FirstOrDefault(); - CueProfileDevice cpd; return (device != null && _devices.TryGetValue(device, out cpd)) ? cpd.Modes : new string[0]; } @@ -66,7 +69,8 @@ namespace CUE.NET.Profiles .ToDictionary(x => x.Name) }; } - catch // I have no idea how the factory pattern should handle such a case - time to read :p + // ReSharper disable once CatchAllClause - I have no idea how the factory pattern should handle such a case - time to read :p + catch { return null; } diff --git a/Profiles/CueProfileDevice.cs b/Profiles/CueProfileDevice.cs index 15102d6..446dab1 100644 --- a/Profiles/CueProfileDevice.cs +++ b/Profiles/CueProfileDevice.cs @@ -59,7 +59,8 @@ namespace CUE.NET.Profiles .ToDictionary(x => x.Name) }; } - catch // I have no idea how the factory pattern should handle such a case - time to read :p + // ReSharper disable once CatchAllClause - I have no idea how the factory pattern should handle such a case - time to read :p + catch { return null; } diff --git a/Profiles/CueProfileMode.cs b/Profiles/CueProfileMode.cs index 16bf9e8..dbe570f 100644 --- a/Profiles/CueProfileMode.cs +++ b/Profiles/CueProfileMode.cs @@ -63,7 +63,8 @@ namespace CUE.NET.Profiles .ToDictionary(x => x.key, x => x.color) }; } - catch (Exception ex) // I have no idea how the factory pattern should handle such a case - time to read :p + // ReSharper disable once CatchAllClause - I have no idea how the factory pattern should handle such a case - time to read :p + catch { return null; } diff --git a/Profiles/CueProfiles.cs b/Profiles/CueProfiles.cs index d35b9cd..45892df 100644 --- a/Profiles/CueProfiles.cs +++ b/Profiles/CueProfiles.cs @@ -1,4 +1,6 @@ -using System; +// ReSharper disable UnusedMember.Global + +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -67,7 +69,8 @@ namespace CUE.NET.Profiles { return XDocument.Load(CONFIG_FILE).Root?.Elements("value").FirstOrDefault(x => string.Equals(x.Attribute("name")?.Value, "InitialProfile", StringComparison.OrdinalIgnoreCase))?.Value; } - catch // This shouldn't happen but you never know ... + // ReSharper disable once CatchAllClause - This shouldn't happen but you never know ... + catch { return null; } @@ -90,7 +93,8 @@ namespace CUE.NET.Profiles _profileNameMapping.Add(name, id); } } - catch // This shouldn't happen but you never know ... + // ReSharper disable once CatchAllClause - This shouldn't happen but you never know ... + catch { _profileNameMapping.Clear(); }