public void DeserializeContents(ref object value, int version, ISerializationReader reader) { var list = (List <T>)value; var items = reader.ReadSet <T>(SerializationConstants.DefaultValueItemName); list.AddRange(items); }
public void DeserializeContents(ref object value, int version, ISerializationReader reader) { var dictionary = (Dictionary <TKey, TValue>)value; foreach (var kvp in reader.ReadSet <KeyValuePair <TKey, TValue> >("Item")) { dictionary.Add(kvp.Key, kvp.Value); } }
public void DeserializeContents(ref object value, int version, ISerializationReader reader) { LinkedList <T> list = (LinkedList <T>)value; var items = reader.ReadSet <T>(SerializationConstants.DefaultValueItemName); foreach (var cur in items) { list.AddLast((T)cur); } }
public void DeserializeContents(ref object value, int version, ISerializationReader reader) { Array array = (Array)value; var enumerator = reader.ReadSet(_elementType, SerializationConstants.DefaultValueItemName, false).GetEnumerator(); if (array.Rank == 1) { for (int i = 0; i < array.Length && enumerator.MoveNext(); ++i) { array.SetValue(enumerator.Current, i); } } else { int[] index = new int[array.Rank]; RecursiveAssignArray(enumerator, array, index, 0); } while (enumerator.MoveNext()) { // ensures all enumerated items are read } }
public void DeserializeConstructor(out object value, int version, ISerializationReader reader) { int[] lengths = reader.ReadSet <int>("Length").ToArray(); value = Array.CreateInstance(_elementType, lengths); }
public static IEnumerable <T> ReadSet <T>(this ISerializationReader reader, string itemName, bool allowCircularDependencies = false) { return(reader.ReadSet(typeof(T), itemName, allowCircularDependencies).Cast <T>()); }