|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Services
Chapters
Feature Zones
|
IntroductionA common problem that developers have with serialization is dealing with the unknown derived classes of the serialized types. Often serialization errors occur when A common workaround is to register those derived types using the This is unacceptable for supporting rapid development. To solve the issue of supporting elegant and rapid development, I have created a simple service to make use of the The solution presented is easy to use, elegant and requires a minimum of developer intervention to implement and make use of. Using the CodeThe use of this code is very simple and requires two things. The first requirement is that you adorn your class declarations with the custom attribute Adorn a class with the required attributes like this: [Serializable]
// example of registering class and all derived classes
[SerializableExtraType(typeof(Foo))]
// example of registering class with an unrelated class
[SerializableExtraType(typeof(SomethingElse))]
// example of registering with multiple classes in same attribute
[SerializableExtraType(new Type[] { typeof(ClassOne), typeof(ClassTwo) })]
public class Foo { public Foo() {} }
As with all serialization in .NET, all classes to be serialized also require the Here is an example of serializing and deserializing an object that contains a collection of string s = SerializableExtraTypes.Serialize(someObject, typeof(Foo));
object o = SerializableExtraTypes.Deserialize
(strSomeObject, typeof(SomeObject), typeof(Foo));
That's it. It's very simple code and easy to use but the concept is wonderful in its simplicity and elegance. This in effect is like attaching History
This is the first publication of this method. Please send any comments or suggestions on how to improve it. You can email me at danatcofo@gmail.com
|
|||||||||||||||||||||||||||||||||||||||||||||||||||