Skip to content

Instantly share code, notes, and snippets.

@achvaicer
Created August 1, 2012 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achvaicer/3229916 to your computer and use it in GitHub Desktop.
Save achvaicer/3229916 to your computer and use it in GitHub Desktop.
ServiceStack.Text Deserializer test
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