How to write a Custom DesignerSerializer for an class used by a Activity (WF)

Posted by Stefan Steinegger on Stack Overflow See other posts from Stack Overflow or by Stefan Steinegger
Published on 2010-04-21T13:41:54Z Indexed on 2010/04/21 13:43 UTC
Read the original article Hit count: 332

I have a type which is used in a WF activity. It should be serialized. It doesn't work out of the box, most probably because of the private setters in that type.

I'm not sure if this is the correct way, but I tried to write my own serializer and declared it on my class.

[DesignerSerializer(
  typeof(FooDesignerSerializer), // my custom serializer
  typeof(WorkflowMarkupSerializer))]
public class Foo
{
  public Foo(int value, string name 
  {
    // ...
  }

  public int Value { get; private set; }
  public string Name { get; private set; }
}

Is this the easiest way to get it serialized?

How do I write this serializer? That's what I got so far:

public class FooDesignerSerializer : WorkflowMarkupSerializer
{
  protected override string SerializeToString(
    WorkflowMarkupSerializationManager serializationManager, 
    object value)
  {
    // how to create a valid / XOML-like string?
  }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about wf