mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added generic type test to path resolve override
This commit is contained in:
parent
254a8e311f
commit
d8e803c531
@ -116,6 +116,7 @@
|
||||
<Compile Include="Extensions\DirectoryInfoExtensions.cs" />
|
||||
<Compile Include="Extensions\RgbColorExtensions.cs" />
|
||||
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
|
||||
<Compile Include="Extensions\TypeExtensions.cs" />
|
||||
<Compile Include="Models\DataModelDescription.cs" />
|
||||
<Compile Include="Ninject\PluginSettingsProvider.cs" />
|
||||
<Compile Include="Plugins\Abstract\ModuleDataModel.cs" />
|
||||
|
||||
22
src/Artemis.Core/Extensions/TypeExtensions.cs
Normal file
22
src/Artemis.Core/Extensions/TypeExtensions.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user