Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class DictionarySerializerTest : MonoBehaviour {
- void Start () {
- //Declare
- Dictionary<int[,], Columns> testDictionary = new Dictionary<int[,], Columns>();
- List<BlockProperties> properties = new List<BlockProperties>();
- properties.Add(new BlockProperties(16, false));
- testDictionary.Add(new int[,] {{ 12, 4 }}, new Columns(2, 9, properties));
- //Action
- byte[] bArray = DictionarySerializer<int[,], Columns>.Save(testDictionary);
- Dictionary<int[,], Columns> deserializedDictionary = DictionarySerializer<int[,], Columns>.Load(bArray);
- //Assert
- Debug.Log("deserializeDictionary != null : " + deserializedDictionary != null);
- Debug.Log("deserializeDictionary.Count : " + deserializedDictionary.Count);
- foreach (KeyValuePair<int[,], Columns> pair in deserializedDictionary)
- {
- string log = "{";
- for (int i = 0, n = pair.Key.GetLength(0); i < n; i++)
- {
- for (int j = 0, n2 = pair.Key.GetLength(1); j < n2; j++)
- {
- log += pair.Key[i, j] + " ";
- }
- }
- log += "} Column(";
- log += pair.Value.xPos + " ";
- log += pair.Value.yPos + " BlockProperties{";
- for (int i = 0; i < pair.Value.properties.Count; i++)
- {
- log += pair.Value.properties[i].num + " " + pair.Value.properties[i].flag;
- }
- log += "})";
- Debug.Log(log);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment