我在Visual Studio C#中创建了一个UserControl,并将其反向设计为EA。结果是两个部分类。
现在,我正在构建EA中的Activity图,以模拟代码中已有的内容,以便我可以从模型中生成代码。一旦我可以从模型中重新生成现有代码,我将继续通过模型添加其他功能。
我已经创建了一个活动图来为构造函数建模。在构造函数中,我创建了一个Call Operation Action来调用partial类的另一部分的方法。我已将Call Operation Action目标的Classifier设置为其他部分Class。
现在事实证明,EA的开箱即用代码生成似乎并不能很好地处理C#部分类,所以我正在尝试更新模板来支持它们。为了做到这一点,我需要获得目标的分类器。我的目的是验证目标分类器的完全限定名称是否与当前范围内的类的完全限定名称相同。为了做到这一点,我需要获得目标的分类器。
我认为使用插件获取信息非常容易,而且我最终会成为我的方式,但我只想弄清楚是否有办法在没有添加的情况下实现
以下是主.cs文件中的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EIIWEAAddin
{
public partial class EIIWAddinWindow : UserControl
{
public EIIWAddinWindow()
{
InitializeComponent();
}
}
}
以下是designer.cs文件中的代码
namespace EIIWEAAddin
{
partial class EIIWAddinWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(68, 153);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(250, 25);
this.label1.TabIndex = 0;
this.label1.Text = "Hello from the EIIWAddin";
//
// EIIWAddinWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label1);
this.Name = "EIIWAddinWindow";
this.Size = new System.Drawing.Size(459, 371);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}
我提供了包的XMI,除了它太大了,我没有看到在这里上传文件的方法。
以下是C#呼叫操作模板的代码。
%PI=""%
$EQ = "="
$GUID = $parameter1
%if $GUID==""%
%endTemplate%
$sActionName = %EASL_GET("Property", $GUID, "Name")%
$context = %EASL_GET("Property", $GUID, "Context")%
$contextClassifier = %EASL_GET("Property", $context, "Classifier")%
$behavior = %EASL_GET("Property", $GUID, "Behavior")%
$arguments = %EASLList="CallArgument" @separator="," @owner=$GUID @collection="Arguments"%
$target = %EASL_GET("Property", $GUID, "Pin", "Target")%
$sUMLType = %EASL_GET("Property", $GUID, "UMLType")%
$BehParent = %EASL_GET("Property", $behavior, "Parent")%
$sBehName = %EASL_GET("Property", $behavior, "Name")%
%if $sBehName == ""%
/*Warning: $sActionName - Associated behavior not found within the package!!*/
%endTemplate%
%if $sUMLType=="uml:CallBehaviorAction" and $BehParent != "" and $BehParent != classGUID%
/*Warning: $sBehName - Invoking behaviors from other classes - Not Supported!!*/
%endTemplate%
%if $sUMLType=="uml:CallOperationAction" and $BehParent != "" and $BehParent != classGUID and $target==""%
/*Warning: $sBehName - Invoking operations from other classes requires a "target" pin to be configured!!*/
%endTemplate%
%if $target != "" and $BehParent != classGUID%
$partial = %classTag:"partial"%
%if $partial != "true"%
$sPropName = %EASL_GET("Property", $target, "Name")%
%else%
/* JJH: Action Call: Calling an operation on a partial class but not on the part currently in scope */\n
/* JJH: Action Call: className = %className% */\n
$sTargetClassifier = %EASL_GET("Property", $target, "Classifier")
%endIf%
%else%
$sPropName = %EASL_GET("Property", $context, "Name")%
%endIf%
$Result = %EASL_GET("Property", $GUID, "Pin", "Result")%
$sResultName = %EASL_GET("Property",$Result,"Name")%
%if $sResultName != ""%
$sResultName $EQ
%endIf%
%if $sPropName != ""%
$sPropName.
%endIf%
$sBehName($arguments);
我真的只是在接近结尾的这一部分......
%if $target != "" and $BehParent != classGUID%
$partial = %classTag:"partial"%
%if $partial != "true"%
$sPropName = %EASL_GET("Property", $target, "Name")%
%else%
/* JJH: Action Call: Calling an operation on a partial class but not on the part currently in scope */\n
/* JJH: Action Call: className = %className% */\n
$sTargetClassifier = %EASL_GET("Property", $target, "Classifier")
%endIf%
%else%
$sPropName = %EASL_GET("Property", $context, "Name")%
%endIf%
所以,我的问题是,如何从代码模板中获取调用操作操作目标的分类器?