Created
August 1, 2012 19:21
-
-
Save achvaicer/3229916 to your computer and use it in GitHub Desktop.
ServiceStack.Text Deserializer test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using ServiceStack.Text; | |
namespace TestServiceStackText | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var list = new List<Abstract> | |
{ | |
new Base() {PropertyA = "A1"}, | |
new Derived() {PropertyA = "A2", PropertyB = "B2"} | |
}; | |
var serialized = TypeSerializer.SerializeToString(list); | |
var deserialized = TypeSerializer.DeserializeFromString<IList<Abstract>>(serialized); | |
foreach (var item in deserialized) | |
Console.WriteLine(item.GetType().Name); | |
Console.Read(); | |
} | |
} | |
class Derived : Abstract | |
{ | |
public string PropertyB { get; set; } | |
} | |
class Base : Abstract | |
{ | |
} | |
abstract class Abstract | |
{ | |
public string PropertyA { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment