locked
RC Breaks "Hello World" Excample for Writeline activity RRS feed

  • Question

  • I read about the change to literals only supporting value types + string, but the Hello world example will no longer work, and I don't see an easy way around passing in the StringWriter()

    For reference:

    StringWriter writer = new StringWriter();
    Sequence wf = new Sequence
                {
    
               Activities = {
           new WriteLine {Text = "Hello", TextWriter = writer},
           new WriteLine {Text = "World", TextWriter = writer}
                                }
    
           };
     WorkflowInvoker.Invoke(wf);
    Ok, then how would you pass in the writer?  It seems to me that removing a feature to "make less confusing to learn" at this late in the game sounds like a bad idea.
    Brainbench MVP (www.brainbench.com)
    Thursday, February 18, 2010 9:28 PM

Answers

  • Found the solution, but it seems silly to me to have to do it this way!

    StringWriter writer = new StringWriter();
    Sequence wf = new Sequence { Activities = {
    new WriteLine {Text = "Hello", TextWriter = new LambdaValue<TextWriter>(n => writer)}} , new WriteLine {Text = "World", TextWriter = new LambdaValue<TextWriter>(n => writer)}} }
    };
    WorkflowInvoker.Invoke(wf);
    Seriously, do you have to go through using a base lambda expression just to pass a parameter in?  It seems like the "fix" has made Workflow more confusing to work with, not less.

    Brainbench MVP (www.brainbench.com)
    • Edited by Bytemaster Friday, February 19, 2010 12:33 AM Fix formatting
    • Marked as answer by Scott Mason - MSFT Friday, February 19, 2010 3:44 AM
    Friday, February 19, 2010 12:31 AM