Exemplo n.º 1
0
    public static void Test()
    {
        Dictionary <string, object> dict   = new Dictionary <string, object>(1);
        List <FavoriteLevel>        levels = new List <FavoriteLevel>(1);

        levels.Add(new FavoriteLevel("123", 0));
        dict.Add("123", levels);
        var settings = new JsonSerializerSettings();

        settings.TypeNameHandling = TypeNameHandling.All;
        byte[] data = JsonExtensions.SerializeToByteArray(dict, settings);
        Dictionary <string, object> incomingDict = JsonExtensions.DeserializeFromByteArray <Dictionary <string, object> >(data, settings);
        object listBack = incomingDict["123"];

        Debug.Assert(listBack.GetType() == levels.GetType());     // No assert.
    }