Commit 196f206a by liulongfei

程序集检测

parent ca12b975
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 插件程序集
/// </summary>
public interface IPluginAssembly
{
/// <summary>
/// 监测
/// </summary>
void Check();
}
}
......@@ -134,6 +134,7 @@
<Compile Include="Model\Scene\TransitionLogicSceneInfoModel.cs" />
<Compile Include="Model\Setting\SettingPageModel.cs" />
<Compile Include="Model\Task\PackageTaskModel.cs" />
<Compile Include="Plugin\IPluginAssembly.cs" />
<Compile Include="Plugin\IPluginLifeCycle.cs" />
<Compile Include="Plugin\IPluginSettingView.cs" />
<Compile Include="Plugin\IPluginView.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 插件程序集
/// </summary>
public class PluginAssembly : IPluginAssembly
{
public void Check()
{
}
}
}
......@@ -179,6 +179,7 @@
<Compile Include="Page\Group\Widgets\PageNumberEdit.xaml.cs">
<DependentUpon>PageNumberEdit.xaml</DependentUpon>
</Compile>
<Compile Include="PluginAssembly.cs" />
<Compile Include="Plugin\Model\PluginNavigationConfig.cs" />
<Compile Include="Plugin\Service\IPluginService.cs" />
<Compile Include="Preview\VizPreview\Controller\VizPreviewCmdController.cs" />
......
......@@ -41,6 +41,7 @@ namespace VIZ.Package.Service
string[] files = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory);
Type pluginLifeCycleType = typeof(IPluginLifeCycle);
Type pluginAssemblyType = typeof(IPluginAssembly);
foreach (string file in files)
{
......@@ -53,6 +54,42 @@ namespace VIZ.Package.Service
string version = assembly.GetCustomAttribute<AssemblyVersionAttribute>()?.Version;
Type[] types = assembly.GetTypes();
// 是否通过检测
bool checkPass = false;
foreach (Type type in types)
{
if (!type.IsClass)
continue;
if (!pluginAssemblyType.IsAssignableFrom(type))
continue;
IPluginAssembly pluginAssembly = type.Assembly.CreateInstance(type.FullName) as IPluginAssembly;
if (pluginAssembly == null)
{
log.Error($"check plugin assembly type: {type.FullName} error.");
continue;
}
try
{
pluginAssembly.Check();
checkPass = true;
break;
}
catch (Exception ex)
{
log.Error(ex);
break;
}
}
// 检测未通过
if (!checkPass)
continue;
// 检测通过
foreach (Type type in types)
{
if (!type.IsClass)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
namespace VIZ.Package.TestPlugin
{
/// <summary>
/// 插件程序集
/// </summary>
public class PluginAssembly : IPluginAssembly
{
public void Check()
{
}
}
}
......@@ -3,6 +3,8 @@ using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using VIZ.Framework.Core;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
......@@ -31,13 +33,13 @@ using System.Windows;
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
......@@ -53,3 +55,5 @@ using System.Windows;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ApplicationDllCheck(Key = "V1.2.0.04041049_beta")]
\ No newline at end of file
......@@ -69,6 +69,7 @@
<Compile Include="Module\TestModuleViewModel.cs" />
<Compile Include="Module\TestModulePluginLifeCycle.cs" />
<Compile Include="Page\TestPagePluginLifeCycle.cs" />
<Compile Include="PluginAssembly.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment