Plugins - local copied to the app folder

This commit is contained in:
Stoyan Zlatev
2024-06-05 13:56:32 +02:00
parent f7b4a13fb7
commit 09d88e5bdc
13 changed files with 131 additions and 64 deletions
+5 -11
View File
@@ -1,23 +1,17 @@
namespace CommonConsole namespace CommonConsole
{ {
using Common.SqlExtensions;
using OmniPlus;
using OmniPlus.Features;
using System; using System;
using System.Linq; using System.IO;
using System.Threading;
public static class Program public static class Program
{ {
public static void Main() public static void Main()
{ {
var a = 816242311982; var plugins = Directory.CreateDirectory(@"Z:\Programme_Sensus\plugins");
var b = (int)a; var files = plugins.GetFiles("*.Plugins.*.dll", SearchOption.AllDirectories);
Console.WriteLine(a);
Console.WriteLine(b);
Console.ReadKey(); Console.ReadKey();
//var connection = new OmniIrdaConnection("COM36"); //var connection = new OmniIrdaConnection("COM36");
//connection.StateChenged += Console.WriteLine; //connection.StateChenged += Console.WriteLine;
//connection.Open(); //connection.Open();
@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -29,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -22,6 +23,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<RegisterForComInterop>false</RegisterForComInterop> <RegisterForComInterop>false</RegisterForComInterop>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -30,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -29,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -29,10 +31,14 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@@ -74,7 +80,6 @@
</PreBuildEvent> </PreBuildEvent>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>xcopy "$(TargetDir)*.*" "\\sla12file\auftrag\Programme_Sensus\plugins\omni" /Y</PostBuildEvent>
</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
@@ -136,8 +136,8 @@
if (firstTP && flush > 0) if (firstTP && flush > 0)
{ {
firstTP = false; firstTP = false;
_ = new ManualResetEventSlim() var awaiter = new ManualResetEventSlim();
.Wait(flush, this.cancellationToken); awaiter.Wait(flush, this.cancellationToken);
} }
if (this.cancellationToken.IsCancellationRequested) if (this.cancellationToken.IsCancellationRequested)
@@ -12,6 +12,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -29,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
+4 -4
View File
@@ -4,12 +4,12 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup> </startup>
<appSettings> <appSettings>
<add key="PluginsDirectory" value="\\sla12file\Auftrag\Programme_Sensus\plugins"/> <add key="PluginsDirectory" value="Z:\Programme_Sensus\plugins"/>
<add key="PSNR" value="0000"/> <add key="PSNR" value="0000"/>
<!--<add key="HubURL" value="http://localhost:52822/LaaProductionWeb" />--> <!--<add key="HubURL" value="http://localhost:52822/LaaProductionWeb" />-->
<add key="HubURL" value="http://sla12iis01.emea.sensus.net/LaaProductionWeb" /> <add key="HubURL" value="http://sla12iis01.emea.sensus.net/LaaProductionWeb"/>
<add key="LaaProductionWeb" value="http://localhost:52822/LaaProductionWeb/" /> <add key="LaaProductionWeb" value="http://localhost:52822/LaaProductionWeb/"/>
<add key="RemoteControl" value="http://localhost:52822/LaaProductionWeb" /> <add key="RemoteControl" value="http://localhost:52822/LaaProductionWeb"/>
<add key="OmniDB" value="Server=SLASQL01.emea.sensus.net; Database=Auftrag; User ID=sa; Password=sqlserver;"/> <add key="OmniDB" value="Server=SLASQL01.emea.sensus.net; Database=Auftrag; User ID=sa; Password=sqlserver;"/>
<add key="COMPorts" value="COM36"/> <add key="COMPorts" value="COM36"/>
<add key="FlushMinutes" value=""/> <add key="FlushMinutes" value=""/>
@@ -15,6 +15,23 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>Z:\Programme_Sensus\InspectionUI\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<InstallUrl>\\sla12file\Auftrag\Programme_Sensus\InspectionUI\</InstallUrl>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -25,6 +42,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -34,6 +52,19 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>CF3FEABBF7AAC02E604ED3DE12ADF685DE6828DB</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>InspectionUI_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.AspNet.SignalR.Client, Version=2.4.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="Microsoft.AspNet.SignalR.Client, Version=2.4.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -136,18 +167,20 @@
<Project>{C6BFAC88-5647-4131-90B1-4D6265E08348}</Project> <Project>{C6BFAC88-5647-4131-90B1-4D6265E08348}</Project>
<Name>InspectionUI.Abstraction</Name> <Name>InspectionUI.Abstraction</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\InspectionUI.Plugins.Controls\InspectionUI.Plugins.Controls.csproj">
<Project>{ebf13d20-08c9-4984-8b21-6fb7419a622a}</Project>
<Name>InspectionUI.Plugins.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\InspectionUI.Plugins.Omni\InspectionUI.Plugins.Omni.csproj">
<Project>{8e1431e9-9b14-4bc2-8b65-47357c97b1fc}</Project>
<Name>InspectionUI.Plugins.Omni</Name>
</ProjectReference>
<ProjectReference Include="..\InspectionUI.RemoteControl\InspectionUI.RemoteControl.csproj"> <ProjectReference Include="..\InspectionUI.RemoteControl\InspectionUI.RemoteControl.csproj">
<Project>{41E949AD-FBF6-47A3-AC1D-7E17AB7F1252}</Project> <Project>{41E949AD-FBF6-47A3-AC1D-7E17AB7F1252}</Project>
<Name>InspectionUI.RemoteControl</Name> <Name>InspectionUI.RemoteControl</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy "$(TargetDir)*.*" "\\sla12file\vorlagen\Stoyan\OMNI prüfung\InspectionUI" /Y</PostBuildEvent>
</PropertyGroup>
</Project> </Project>
@@ -34,6 +34,7 @@
Padding="5" Padding="5"
SelectedValue="{Binding Plugin}" SelectedValue="{Binding Plugin}"
Style="{DynamicResource ComboBoxStyle}" Style="{DynamicResource ComboBoxStyle}"
Visibility="{Binding PluginsDropdownVisibility}"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
MinWidth="150" /> MinWidth="150" />
<TextBox Grid.Column="1" <TextBox Grid.Column="1"
@@ -17,6 +17,7 @@
private TestBench testBench; private TestBench testBench;
private PluginsManager pluginsManager; private PluginsManager pluginsManager;
private Visibility notificationsVisibility; private Visibility notificationsVisibility;
private Visibility pluginsDropdownVisibility;
public MainWindowVM() : base() public MainWindowVM() : base()
{ {
@@ -32,6 +33,7 @@
this.testBench.Notification += notification this.testBench.Notification += notification
=> this.Notifications = notification; => this.Notifications = notification;
this.notificationsVisibility = Visibility.Collapsed; this.notificationsVisibility = Visibility.Collapsed;
this.pluginsDropdownVisibility = Visibility.Collapsed;
this.LoadAvailablePlugins(); this.LoadAvailablePlugins();
} }
@@ -116,6 +118,12 @@
set => this.Set(() => this.notificationsVisibility = value); set => this.Set(() => this.notificationsVisibility = value);
} }
public Visibility PluginsDropdownVisibility
{
get => this.pluginsDropdownVisibility;
set => this.Set(() => this.pluginsDropdownVisibility = value);
}
public ItemsGridVM ItemsGridSource { get; } public ItemsGridVM ItemsGridSource { get; }
public ICommand LoadInspectionParameters { get; } public ICommand LoadInspectionParameters { get; }
@@ -137,7 +145,6 @@
base.Dispose(); base.Dispose();
this.testBench?.Dispose(); this.testBench?.Dispose();
this.TestBatch?.Dispose(); this.TestBatch?.Dispose();
this.pluginsManager?.Dispose();
} }
private void OnLoadInspectionParameters() private void OnLoadInspectionParameters()
@@ -232,6 +239,16 @@
{ {
this.DispatcherInvoke(() => this.Plugins.Add(plugin)); this.DispatcherInvoke(() => this.Plugins.Add(plugin));
} }
if (this.Plugins.Count == 1)
{
this.Plugin = this.Plugins[0];
}
this.PluginsDropdownVisibility
= this.Plugins.Count > 1
? Visibility.Visible
: Visibility.Collapsed;
}) })
.ContinueWith(task => .ContinueWith(task =>
{ {
@@ -13,8 +13,6 @@
{ {
private readonly IDictionary<string, Type> entryPoints private readonly IDictionary<string, Type> entryPoints
= new Dictionary<string, Type>(); = new Dictionary<string, Type>();
private readonly AppDomain pluginsDomain
= AppDomain.CreateDomain("Plugins");
internal bool IsActivated { get; private set; } internal bool IsActivated { get; private set; }
@@ -23,7 +21,7 @@
if (!string.IsNullOrWhiteSpace(plugin) && this.entryPoints.ContainsKey(plugin)) if (!string.IsNullOrWhiteSpace(plugin) && this.entryPoints.ContainsKey(plugin))
{ {
var entryPoint = this.entryPoints[plugin]; var entryPoint = this.entryPoints[plugin];
var instance = Activator.CreateInstance(entryPoint, testBench, App.Appsettings); var instance = Activator.CreateInstance(entryPoint, new object[] { testBench, App.Appsettings });
if (instance is ITestBatch testBatch) if (instance is ITestBatch testBatch)
{ {
@@ -36,39 +34,23 @@
internal IEnumerable<string> AvailablePlugins() internal IEnumerable<string> AvailablePlugins()
{ {
var plugins = Directory.GetFiles(App.Appsettings.CurrentDirectory, "InspectionUI.Plugins.*.dll", SearchOption.AllDirectories); var localDirectory = Path.GetDirectoryName(typeof(PluginsManager).Assembly.Location);
var assemblyName = default(AssemblyName);
var assembly = default(Assembly);
foreach (var plugin in plugins) CopyDirectories(App.Appsettings.PluginsDirectory, localDirectory);
var pluginFiles = Directory.GetFiles(localDirectory, "*Plugins*.dll", SearchOption.AllDirectories);
foreach (var pluginFile in pluginFiles)
{ {
assemblyName = AssemblyName.GetAssemblyName(plugin); var assembly = Assembly.LoadFrom(pluginFile);
assembly = this.pluginsDomain.Load(assemblyName); var entryPoint = assembly
.GetTypes()
var types = assembly.GetTypes(); .FirstOrDefault(x => !x.IsAbstract && typeof(TestBatchBase).IsAssignableFrom(x));
var entryPoint = types.FirstOrDefault(x => !x.IsAbstract var name = (entryPoint
&& !x.IsInterface .GetCustomAttributes(true)
&& typeof(ITestBatch).IsAssignableFrom(x)); ?.FirstOrDefault(x => x is TestBatchAttribute _)
as TestBatchAttribute)
if (entryPoint is null) ?.DisplayName ?? entryPoint.Name;
{
continue;
}
var name = assemblyName
.Name
.Split('.')
.LastOrDefault();
foreach (var attr in entryPoint.GetCustomAttributes(true))
{
if (attr is TestBatchAttribute testBatchAttribute)
{
name = testBatchAttribute.DisplayName;
break;
}
}
this.entryPoints[name] = entryPoint; this.entryPoints[name] = entryPoint;
@@ -76,7 +58,29 @@
} }
} }
internal void Dispose() private static void CopyDirectories(string sourceDirectory, string destinationDirectory)
=> AppDomain.Unload(this.pluginsDomain); {
CopyFiles(sourceDirectory, destinationDirectory);
foreach (var subDirectory in Directory.GetDirectories(sourceDirectory))
{
var subDirectoryName = new DirectoryInfo(subDirectory).Name;
var destinationSubDirectoryPath = Path.Combine(destinationDirectory, subDirectoryName);
var destinationSubDirectory = Directory.CreateDirectory(destinationSubDirectoryPath).FullName;
CopyDirectories(subDirectory, destinationSubDirectory);
}
}
private static void CopyFiles(string sourceDirectory, string destinationDirectory)
{
foreach (var sourceFile in Directory.GetFiles(sourceDirectory))
{
var sourceFileName = Path.GetFileName(sourceFile);
var destinationFile = Path.Combine(destinationDirectory, sourceFileName);
File.Copy(sourceFile, destinationFile, true);
}
}
} }
} }
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="AppDomainToolkit" version="1.0.4.3" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.Client" version="2.4.3" targetFramework="net40" /> <package id="Microsoft.AspNet.SignalR.Client" version="2.4.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" requireReinstallation="true" /> <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" requireReinstallation="true" />
</packages> </packages>