Commit f61fe3cb by wangonghui

Merge branch 'master' into DevPackage

parents c204fc03 fc973f23
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,7 +134,6 @@
<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,7 +179,6 @@
<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,7 +41,6 @@ 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)
{
......@@ -51,45 +50,10 @@ namespace VIZ.Package.Service
continue;
Assembly assembly = Assembly.LoadFile(file);
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)
......@@ -112,7 +76,17 @@ namespace VIZ.Package.Service
if (!string.Equals(entry_attribute.Key, attribute.Key))
continue;
PluginInfo info = lifeCycle.Register();
PluginInfo info = null;
try
{
info = lifeCycle.Register();
}
catch (Exception ex)
{
log.Error(ex);
break;
}
list.Add(info);
}
}
......
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