![](/img/trans.png)
[英]Serializing Custom types that are set from UITypeEditor at design Time
[英]Get/Set Workflow Variable from uiTypeEditor
我創建了一個自定義ui編輯器來處理為我的工作流設置變量的值。 我想做的就是能夠獲取uieditor中為工作流設置的任何變量的值。
public class MyCustomEditor : UITypeEditor
{
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value){
IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
IBuildDefinition buildDefinition = (IBuildDefinition)provider.GetService(typeof(IBuildDefinition));
// Variable set in the workflow metadata to use this ui editor
MyCustomVariable variable = value as MyCustomVariable;
// Tried getting it from the Process Parameters but the only thing in there was BuildSettings
var processParms = WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters);
object obj;
processParms.TryGetValue("BuildSettings", out obj);
BuildSettings buildSettings = obj as BuildSettings;
// I want to be able to access other variable for the workflow, everything above works. But MyCustomVariable is set in the Metadata to use this editor. I want to get the value of another variable in the workflow as well
return variable;
}
}
我錯了,當我查看ProcessParameters時,尚未保存構建定義,因此這就是為什么我只看到“ BuildSettings”的原因。一旦在保存的BuildDefinition上反序列化它們,便可以看到所有變量。
var processParms = WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters);
object obj;
processParms.TryGetValue("MyOtherVariable", out obj);
MyOtherVariable myOtherVariable = obj as MyOtherVariable;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.