0
votes

I created the following equivalent of an alias:

public class TagAttributes : Dictionary<String, String> { }

Code Analysis stated I need to mark this as serializable, which I did.

[Serializable()]
public class TagAttributes : Dictionary<String, String> { }

Next, Code Analysis stated I need to include a constructor with the following signature:

protected TagAttributes(SerializationInfo info, StreamingContext context)

From this, I know that the following method would also have to be included:

public override void GetObjectData(SerializationInfo info, StreamingContext context)

My question is, what do I put inside these methods? There is no instance, so there's nothing to reference for the serialization. This is an "alias".

I assume I would mark them as virtual. But even then, what would I have to put inside in order to serialize the dictionary instance.

2

2 Answers

3
votes

Since your class derives from Dictionary<string, string> and is most likely just adding a few extras, you could just call the base class constructor. http://msdn.microsoft.com/en-us/library/dx4ybycc.aspx

2
votes

If you want an alias, use this:

using TagAttributes = System.Collections.Generic.Dictionary<string, string>;