diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index b190fa0a4..ac35c3c37 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -116,6 +116,7 @@ + diff --git a/src/Artemis.Core/Extensions/TypeExtensions.cs b/src/Artemis.Core/Extensions/TypeExtensions.cs new file mode 100644 index 000000000..7676a96dd --- /dev/null +++ b/src/Artemis.Core/Extensions/TypeExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Artemis.Core.Extensions +{ + public static class TypeExtensions + { + public static bool IsGenericType(this Type type, Type genericType) + { + if (type == null) + return false; + var baseType = type.BaseType; + if (baseType == null) + return false; + + return baseType.GetGenericTypeDefinition() == genericType; + } + } +} diff --git a/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs b/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs index eef33aebf..c452c07ed 100644 --- a/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs +++ b/src/Artemis.Plugins.Devices.Corsair/CorsairDevice.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Reflection; +using Artemis.Core.Extensions; using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Models; using Artemis.Core.Services.Interfaces; @@ -30,7 +31,7 @@ namespace Artemis.Plugins.Devices.Corsair private void ResolveCorsairPath(object sender, ResolvePathEventArgs e) { - if (e.RelativePart.Contains("Layouts\\Corsair")) + if (sender.GetType().IsGenericType(typeof(CorsairRGBDevice<>))) { // Start from the plugin directory e.FinalPath = Path.Combine(PluginInfo.Directory.FullName, e.RelativePart, e.FileName);