C# 在自定义活动中创建TypeArgument文本框
我最近开始使用UiPath在工作中创建自动流程。我尝试过创建自定义活动 其中一项活动称为AddToDictionary。它是通用的,因为用户需要指定字典将存储的KeyValPair类型C# 在自定义活动中创建TypeArgument文本框,c#,.net,workflow-foundation,uipath,C#,.net,Workflow Foundation,Uipath,我最近开始使用UiPath在工作中创建自动流程。我尝试过创建自定义活动 其中一项活动称为AddToDictionary。它是通用的,因为用户需要指定字典将存储的KeyValPair类型 [DisplayName("Add to dictionary")] [Description("Adds a KeyValuePair to a dictionary.")] public sealed class AddToDictionary<TKey, TValue>
[DisplayName("Add to dictionary")]
[Description("Adds a KeyValuePair to a dictionary.")]
public sealed class AddToDictionary<TKey, TValue> : CodeActivity
{
[Category("Input")]
[RequiredArgument]
[DisplayName("Dictionary target")]
[Description("The target dictionary, which the KeyValuePair will be added to.")]
public InArgument<Dictionary<TKey, TValue>> Dictionary { get; set; }
[Category("Input")]
[RequiredArgument]
[Description("The key object, which will be added to the target dictionary")]
public InArgument<TKey> Key { get; set; }
[Category("Input")]
[RequiredArgument]
[Description("The value object, which will be added to the target dictionary")]
public InArgument<TValue> Value { get; set; }
protected override void Execute(CodeActivityContext context)
{
var key = Key.Get(context);
var value = Value.Get(context);
Dictionary.Get(context).Add(key, value);
}
}
[DisplayName(“添加到字典”)]
[说明(“将KeyValuePair添加到字典。”)]
公共密封类AddToDictionary:CodeActivity
{
[类别(“输入”)]
[必需参数]
[显示名称(“字典目标”)]
[说明(“KeyValuePair将添加到的目标字典。”)]
公共非语法词典{get;set;}
[类别(“输入”)]
[必需参数]
[说明(“将添加到目标词典的密钥对象”)]
公共InArgument密钥{get;set;}
[类别(“输入”)]
[必需参数]
[说明(“将添加到目标字典的值对象”)]
公共InArgument值{get;set;}
受保护的覆盖无效执行(CodeActivityContext上下文)
{
var key=key.Get(上下文);
var value=value.Get(上下文);
Dictionary.Get(context).Add(key,value);
}
}
现在活动在UiPath中运行良好,没有问题。
但当我将活动拖到工作流中时,会弹出一个窗口,询问类型。现在我更希望在右边的属性窗口中有一个下拉菜单,选择你自己的类型
我一直在互联网上搜寻开源代码,但到目前为止没有找到任何东西。要获得下拉列表,您可以使用源代码,或者我不确定如何将其绑定到对象类型。在将活动放到画布上之前,需要解析泛型类型。这就是弹出窗口询问类型的原因。