How to write a Custom DesignerSerializer for an class used by a Activity (WF)
- by Stefan Steinegger
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?
}
}