Custom Activity with Pre-Set InArgument expression RRS feed

  • Question

  • I'm writing a workflow wrapper around a document processing library.

    The library has (amongst other things) methods to open and close documents, I'm making matching workflow activities with custom designers.

    The OpenDocument activity has

    public InArgument<string> FileName {get;set;}

    public OutArgument<DocumentObject> Document {get;set;}

    Its custom designer has a button that pop open file dialog and sets the FileName; The Document is initialized in the constructor of OpenDocument:

    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Consolas; color: #63a0bb} span.s1 {color: #000000} span.s2 {color: #2036fb} span.s3 {color: #9b2b21}

    Document = new OutArgument<DocumentObject>(new VisualBasicReference<DocumentObject>("ActiveDocument"));  

    As a result as soon as a new instance of the activity is dropped into the workflow the Document is set to point to ActiveDocument, the user needs not to change it (the matching variable comes from a template).



    The problem is that CloseDocument activity has 


    public InArgument<DocumentObject> Document {get;set;}


    which I want to set to point to the same default variable as the OpenDocument activity, but I can't find out how. Trying to use similar approach as OpenDocument fails:

      Document = new InArgument<DocumentObject>(new VisualBasicReference<DocumentObject>("ActiveDocument"));

    doesn't compile as do several other things I've tried to use (Literal<> requires an instance)



    How do I set the InArgument in CloseDocument to point by default to some of the workflow's Variables?

    Friday, June 17, 2011 2:28 AM


  • Another one that I answered myself:


    FromSelection = new InArgument<SelectionObject>(new VisualBasicValue<SelectionObject>("ActiveSelection"));


    to initialize the InArgument one has to use VisualBasicValue

    • Proposed as answer by Andrew_Zhu Wednesday, June 22, 2011 2:55 AM
    • Marked as answer by Andrew_Zhu Wednesday, June 22, 2011 2:55 AM
    Friday, June 17, 2011 6:56 PM