Exemple #1
0
        public void OnBeforeSerialize()
        {
            var bf = new BinaryFormatter(UnitySerializationSurrogateSelector.GetSurrogateSelector(), new StreamingContext());

            using (var ms = new MemoryStream())
            {
                bf.Serialize(ms, things);
                bytes = ms.ToArray();
            }
        }
Exemple #2
0
        public void OnAfterDeserialize()
        {
            if (bytes == null || bytes.Length == 0)
            {
                return;
            }
            var bf = new BinaryFormatter(UnitySerializationSurrogateSelector.GetSurrogateSelector(), new StreamingContext());

            using (var ms = new MemoryStream(bytes))
            {
                things = (Dictionary <string, object>)bf.Deserialize(ms);
            }
        }