WF4RC, WriteLine operation throws an error in the StringWriter assigned by TextWriter

I am new to Windows Workflow [WF] and interested in evaluating WF for business purposes. I decided to work through the introduction

[TestMethod]
public void TestMethod ()
{
    TextWriter writer = new StringWriter ();
    Sequence sequence = new Sequence
    {
        Activities =
        {
            // so, assigning a reference type [eg StringWriter]
            // as target is prohibited in WF4RC. what or how do
            // i assign a target? introduction cited above may
            // not be current [ie may be Beta2, not RC] so ... ?
            new WriteLine { Text = "Hello", TextWriter = writer },
            new WriteLine { Text = "World", TextWriter = writer }
        }
    };
    // !!! BLOWS UP !!!
    WorkflowInvoker.Invoke (sequence);
}

and ran into

The SomeTests.SomeTests.TestMethod test method threw an exception: System.Activities.InvalidWorkflowException: The following errors occurred while processing the workflow tree: 'Literal': Literal only supports value types and the immutable type System.String. The type System.IO.TextWriter cannot be used as a literal.

Shaking, I found this article describing what seems like the error I see above.

Being new to WF, I really don't understand the change or the prescribed method to get around it. So my question is:

WF4RC, [] WriteLine ?

+5
2

Ack, k, so mind note: Google. this

WriteLine WF RC

, LambdaValue<T>, comme ca

[TestMethod]
public void TestMethod ()
{
    StringWriter writer = new StringWriter ();
    Sequence sequence = 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 (sequence);
    Assert.
        AreEqual (
        "Hello\r\nWorld\r\n", 
        writer.GetStringBuilder ().ToString ());
}

, "": P

- , - .

+8

...

TextWriter - InArgument, (, Text). InArgument (, , ActivityContext ).

, InArgument Literal . . , , .

LambdaValue a () . , .

, , .

0

All Articles