public static void DeserializeField(DeserializeContext context, BinaryReader br, ref string value) { if (!context.Walk(ref value)) { return; } value = br.ReadString(); // TODO: one day we might like to not allocate here. context.VisitObject(value); }
public static void DeserializeArrayField <T>(DeserializeContext context, BinaryReader br, ref T[] array) { if (!context.Walk(ref array)) { return; } array = new T[br.ReadSmallInt32()]; context.VisitObject(array); for (var i = 0; i < array.Length; i++) { Field.Deserialize(context, br, ref array[i]); } }
public static void DeserializeField(DeserializeContext context, BinaryReader br, ref StringBuilder stringBuilder) { if (!context.Walk(ref stringBuilder)) { return; } var length = br.ReadSmallInt32(); stringBuilder = new StringBuilder(length); stringBuilder.Length = length; context.VisitObject(stringBuilder); for (var i = 0; i < length; i++) { stringBuilder[i] = br.ReadChar(); } }
private static void DeserializeDelegate(DeserializeContext context, BinaryReader br, ref Delegate d, Type delegateType) { Debug.Assert(StaticDelegateTable.delegateTypeTable.ContainsKey(delegateType)); var delegateTypeInfo = StaticDelegateTable.delegateTypeTable[delegateType]; var delegateMethodInfo = delegateTypeInfo.GetMethodInfoForId(br.ReadInt32()); object target = null; if (delegateMethodInfo.canHaveTarget) { if (context.Walk(ref target)) { target = StaticDispatchTable.DeserializationDispatcher(context, br); // (see comment in the SerializeDelegate method) } } d = Delegate.CreateDelegate(delegateType, target, delegateMethodInfo.method); }
public static void DeserializeArray2DField <T>(DeserializeContext context, BinaryReader br, ref T[,] array) { if (!context.Walk(ref array)) { return; } int length0, length1; array = new T[length0 = br.ReadSmallInt32(), length1 = br.ReadSmallInt32()]; context.VisitObject(array); for (var i = 0; i < length0; i++) { for (var j = 0; j < length1; j++) // NOTE: Arrays are contiguious on their rightmost (last) dimension { Field.Deserialize(context, br, ref array[i, j]); } } }
public static void DeserializeArray3DField <T>(DeserializeContext context, BinaryReader br, ref T[,,] array) { if (!context.Walk(ref array)) { return; } int length0, length1, length2; array = new T[length0 = br.ReadSmallInt32(), length1 = br.ReadSmallInt32(), length2 = br.ReadSmallInt32()]; context.VisitObject(array); for (var i = 0; i < length0; i++) { for (var j = 0; j < length1; j++) { for (var k = 0; k < length2; k++) { Field.Deserialize(context, br, ref array[i, j, k]); } } } }
public static void DeserializeField(DeserializeContext context, BinaryReader br, ref StateProvider.State value) { context.Walk(ref value); }