added IPluginBase for upcoming Plugin System

This commit is contained in:
WeeXnes 2025-04-08 12:20:04 +02:00
parent 111c511ac9
commit b832aafa7c
9 changed files with 131 additions and 2 deletions

View file

@ -14,6 +14,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>wicns.ico</ApplicationIcon> <ApplicationIcon>wicns.ico</ApplicationIcon>
<LangVersion>12</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>

View file

@ -14,6 +14,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>wicns.ico</ApplicationIcon> <ApplicationIcon>wicns.ico</ApplicationIcon>
<LangVersion>12</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>

View file

@ -0,0 +1,12 @@
using System;
namespace WXPlugin.PluginCore
{
public interface IPluginBase
{
public String Name { get; set; }
public String Description { get; set; }
public void Initialize();
public void Execute();
}
}

55
WXPlugin/WXPlugin.csproj Normal file
View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{56BFE4E0-0D30-474A-B57B-CF08515FF66E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WXPlugin</RootNamespace>
<AssemblyName>WXPlugin</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>12</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="PluginCore\IPluginBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeeXnes_UAC", "WeeXnes_UAC\
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{133FF515-D605-4856-BA2E-5841BF47EC2F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csproj", "{133FF515-D605-4856-BA2E-5841BF47EC2F}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WXPlugin", "WXPlugin\WXPlugin.csproj", "{56BFE4E0-0D30-474A-B57B-CF08515FF66E}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -30,5 +32,9 @@ Global
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.Build.0 = Debug|Any CPU {133FF515-D605-4856-BA2E-5841BF47EC2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.ActiveCfg = Release|Any CPU {133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.Build.0 = Release|Any CPU {133FF515-D605-4856-BA2E-5841BF47EC2F}.Release|Any CPU.Build.0 = Release|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using WXPlugin.PluginCore;
namespace WeeXnes.Core;
public class PluginManager
{
private HashSet<String> Directories = new HashSet<String>();
public HashSet<IPluginBase> CurrentPlugins { get; set; } = new HashSet<IPluginBase>();
public PluginManager(String pluginPath)
{
Directories.Add(pluginPath);
}
public void LoadPlugins()
{
CurrentPlugins = new HashSet<IPluginBase>();
foreach (var dir in Directories)
{
DirectoryInfo dirInfo = new DirectoryInfo(dir);
foreach (var file in dirInfo.GetFiles("*.dll"))
{
Assembly asm = Assembly.LoadFrom(file.FullName);
foreach (Type type in asm.GetTypes())
{
if (type.IsSubclassOf(typeof(IPluginBase)) || type.GetInterfaces().Contains(typeof(IPluginBase)) && type.IsAbstract == false)
{
IPluginBase newPlugin = type.InvokeMember(
null,
BindingFlags.CreateInstance,
null,
null,
null)
as IPluginBase;
CurrentPlugins.Add(newPlugin);
}
}
}
}
}
}

View file

@ -103,7 +103,8 @@
Icon="InprivateAccount24" Icon="InprivateAccount24"
Name="ButtonProfile" Name="ButtonProfile"
PageTag="Profile" PageTag="Profile"
PageType="{x:Type profile:LoginView}"/> PageType="{x:Type profile:LoginView}"
Visibility="Collapsed"/>
</ui:NavigationStore.Items> </ui:NavigationStore.Items>
<ui:NavigationStore.Footer> <ui:NavigationStore.Footer>
<ui:NavigationItem <ui:NavigationItem

View file

@ -15,7 +15,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>wicns.ico</ApplicationIcon> <ApplicationIcon>wicns.ico</ApplicationIcon>
<LangVersion>10</LangVersion> <LangVersion>12</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -75,6 +75,7 @@
<Compile Include="Core\EncryptorLibrary.cs" /> <Compile Include="Core\EncryptorLibrary.cs" />
<Compile Include="Core\HandleLaunchArguments.cs" /> <Compile Include="Core\HandleLaunchArguments.cs" />
<Compile Include="Core\LoginLib.cs" /> <Compile Include="Core\LoginLib.cs" />
<Compile Include="Core\PluginManager.cs" />
<Compile Include="Core\RpcLogEvents.cs" /> <Compile Include="Core\RpcLogEvents.cs" />
<Compile Include="Core\SaveSettingsHandler.cs" /> <Compile Include="Core\SaveSettingsHandler.cs" />
<Compile Include="Core\WXFile.cs" /> <Compile Include="Core\WXFile.cs" />
@ -200,5 +201,11 @@
<Content Include="wicns.ico" /> <Content Include="wicns.ico" />
<Resource Include="Images\wicon.png" /> <Resource Include="Images\wicon.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WXPlugin\WXPlugin.csproj">
<Project>{56bfe4e0-0d30-474a-b57b-cf08515ff66e}</Project>
<Name>WXPlugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View file

@ -13,6 +13,7 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<LangVersion>12</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>