添加项目文件。
This commit is contained in:
6
TestAddinPlugin/App.config
Normal file
6
TestAddinPlugin/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
36
TestAddinPlugin/Properties/AssemblyInfo.cs
Normal file
36
TestAddinPlugin/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("TestAddinPlugin")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TestAddinPlugin")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("013a0d0a-5c3f-4510-acc0-ccb8c86cc4fc")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
20
TestAddinPlugin/TestAddin/Commands.xml
Normal file
20
TestAddinPlugin/TestAddin/Commands.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<KeyinTree xmlns="http://www.bentley.com/schemas/1.0/MicroStation/AddIn/KeyinTree.xsd">
|
||||
<RootKeyinTable ID="root">
|
||||
<Keyword SubtableRef="subKeyin" CommandWord="TestPlugin">
|
||||
<Options Required="false"/>
|
||||
</Keyword>
|
||||
</RootKeyinTable>
|
||||
|
||||
<SubKeyinTables>
|
||||
<KeyinTable ID="subKeyin">
|
||||
<Keyword CommandWord="element" />
|
||||
<Keyword CommandWord="addin" />
|
||||
</KeyinTable>
|
||||
</SubKeyinTables>
|
||||
|
||||
<KeyinHandlers>
|
||||
<KeyinHandler Keyin="TestPlugin element" Function="TestAddinPlugin.TestAddin.PluginKeyinFuncs.TestElement" />
|
||||
<KeyinHandler Keyin="TestPlugin addin" Function="TestAddinPlugin.TestAddin.PluginKeyinFuncs.TestAddin" />
|
||||
</KeyinHandlers>
|
||||
</KeyinTree>
|
||||
36
TestAddinPlugin/TestAddin/PluginAddin.cs
Normal file
36
TestAddinPlugin/TestAddin/PluginAddin.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Bentley.MstnPlatformNET;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MSAddinTest.MSTestInterface;
|
||||
|
||||
namespace TestAddinPlugin.TestAddin
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试 addin 调试
|
||||
/// 1. 继承抽象类 MSTest_Addin
|
||||
/// 2. 在 Init 中获取传递的 addin 供当前库使用
|
||||
/// </summary>
|
||||
[AddIn(MdlTaskID = "TestAddinPlugin")]
|
||||
internal class PluginAddin : MSTest_Addin
|
||||
{
|
||||
public static AddIn Instance { get; private set; }
|
||||
public PluginAddin(IntPtr mdlDescriptor) : base(mdlDescriptor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Init(AddIn addin)
|
||||
{
|
||||
Instance = addin;
|
||||
Run(new string[] { });
|
||||
}
|
||||
|
||||
protected override int Run(string[] commandLine)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
24
TestAddinPlugin/TestAddin/PluginKeyinFuncs.cs
Normal file
24
TestAddinPlugin/TestAddin/PluginKeyinFuncs.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using MSAddinTest.MSTestInterface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TestAddinPlugin.TestAddin
|
||||
{
|
||||
internal class PluginKeyinFuncs
|
||||
{
|
||||
[MSTest("element",Description ="这是keyin别名")]
|
||||
public static void TestElement(string unparsed)
|
||||
{
|
||||
MessageBox.Show("我是 keyin,我被调用了");
|
||||
}
|
||||
|
||||
public static void TestAddin(string unparsed)
|
||||
{
|
||||
MessageBox.Show("我是纯 keyin,且我没有被 MSTest 标记,我被调用了");
|
||||
}
|
||||
}
|
||||
}
|
||||
58
TestAddinPlugin/TestAddinPlugin.csproj
Normal file
58
TestAddinPlugin/TestAddinPlugin.csproj
Normal file
@@ -0,0 +1,58 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
<OutputPath>C:\Program Files\Bentley\MicroStation 2024\MicroStation\Mdlapps</OutputPath>
|
||||
<Microstation>C:\Program Files\Bentley\MicroStation 2024\MicroStation</Microstation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>C:\Program Files\Bentley\MicroStation 2024\MicroStation\Mdlapps</OutputPath>
|
||||
</PropertyGroup>
|
||||
<!-- <PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>-->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Bentley.DgnPlatformNET">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(Microstation)\Bentley.DgnPlatformNET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Bentley.GeometryNET">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(Microstation)\Bentley.GeometryNET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Bentley.GeometryNET.Structs">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(Microstation)\Bentley.GeometryNET.Structs.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ustation">
|
||||
<HintPath>$(Microstation)\ustation.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestAddin\Commands.xml">
|
||||
<SubType>Designer</SubType>
|
||||
<LogicalName>CommandTable.xml</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MSAddinTest\MSAddinTest.csproj" />
|
||||
<ProjectReference Include="..\MSUtils\MSUtils.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
22
TestAddinPlugin/TestClassExecutor.cs
Normal file
22
TestAddinPlugin/TestClassExecutor.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TestAddinPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试类执行器
|
||||
/// 1. 继承接口 IMSTest_Class
|
||||
/// 2. 类添加特性 MSTest
|
||||
/// </summary>
|
||||
[MSTest("class", Description = "测试 IClassPlugin 插件,通过 mstest test class 来调用")]
|
||||
public class TestClassExecutor : IMSTest_Class
|
||||
{
|
||||
/// <summary>
|
||||
/// 该接口为实例初始化后的调用入口
|
||||
/// </summary>
|
||||
/// <param name="arg"></param>
|
||||
public void Execute(string arg)
|
||||
{
|
||||
MessageBox.Show("IClassPlugin 被调用了!");
|
||||
}
|
||||
}
|
||||
}
|
||||
57
TestAddinPlugin/TestStaticMethodExecutor.cs
Normal file
57
TestAddinPlugin/TestStaticMethodExecutor.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Bentley.DgnPlatformNET.Elements;
|
||||
using Bentley.GeometryNET;
|
||||
using Bentley.MstnPlatformNET;
|
||||
|
||||
using MSAddinTest.Interfaces;
|
||||
|
||||
using MSUtils;
|
||||
|
||||
namespace TestAddinPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试静态方法
|
||||
/// 1. 类继承接口 IMSTest_StaticMethod
|
||||
/// 2. 静态方法添加特性 MSTest
|
||||
/// 3. 静态方法有且仅有一个IMSTestArg参数
|
||||
/// </summary>
|
||||
public class TestStaticMethodExecutor : IMSTest_StaticMethod
|
||||
{
|
||||
[MSTest("static", Description = "通过 mstest test static 来调用")]
|
||||
public static object Execute(string arg)
|
||||
{
|
||||
MessageBox.Show("IStaticMethodPlugin 被调用了4!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
[MSTest("element")]
|
||||
public static object NewElement(string arg)
|
||||
{
|
||||
// 绘制一个元素
|
||||
CurvePrimitive line = CurvePrimitive.CreateLineString(new List<DPoint3d>()
|
||||
{
|
||||
new DPoint3d(0,0,0),
|
||||
new DPoint3d(100000,0,0),
|
||||
});
|
||||
var instance = Session.Instance;
|
||||
if (instance == null) return false;
|
||||
|
||||
var dgnm = instance.GetActiveDgnModel();
|
||||
Element et = DraftingElementSchema.ToElement(dgnm, line, null);
|
||||
if (et != null) et.AddToModel();
|
||||
|
||||
MessageBox.Show("绘制元素成功!");
|
||||
return true;
|
||||
}
|
||||
|
||||
[MSTest("exception")]
|
||||
public static object TestReference(string arg)
|
||||
{
|
||||
TestClass.NullException();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user