Question

I have created a custom ui editor to handle setting the value of a variable for my workflow. What I want to do is be able to get the value of any of the variables set for the workflow within the 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;
   }
}
Était-ce utile?

La solution

I was wrong, when I was looking at ProcessParameters, the build definition had not yet been saved so that's why I was only seeing 'BuildSettings' Once I deserialize them on a saved BuildDefinition, I could see all the variables.

var processParms = WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters);

object obj;
processParms.TryGetValue("MyOtherVariable", out obj);
MyOtherVariable myOtherVariable = obj as MyOtherVariable;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top