private static long ReadTimeSpanTicks(ProtoReader source) { long num2; switch (source.WireType) { case WireType.Fixed64: return(source.ReadInt64()); case WireType.String: case WireType.StartGroup: { int num; SubItemToken token = ProtoReader.StartSubItem(source); TimeSpanScale days = TimeSpanScale.Days; num2 = 0L; Label_0065: if ((num = source.ReadFieldHeader()) <= 0) { ProtoReader.EndSubItem(token, source); switch (days) { case TimeSpanScale.Days: return(num2 * 0xc92a69c000L); case TimeSpanScale.Hours: return(num2 * 0x861c46800L); case TimeSpanScale.Minutes: return(num2 * 0x23c34600L); case TimeSpanScale.Seconds: return(num2 * 0x989680L); case TimeSpanScale.Milliseconds: return(num2 * 0x2710L); case TimeSpanScale.Ticks: return(num2); case TimeSpanScale.MinMax: { long num4 = num2; if ((num4 <= 1L) && (num4 >= -1L)) { switch (((int)(num4 - -1L))) { case 0: return(-9223372036854775808L); case 2: return(0x7fffffffffffffffL); } } goto Label_0115; } } throw new ProtoException("Unknown timescale: " + days.ToString()); } switch (num) { case 1: source.Assert(WireType.SignedVariant); num2 = source.ReadInt64(); goto Label_0065; case 2: days = (TimeSpanScale)source.ReadInt32(); goto Label_0065; } source.SkipField(); goto Label_0065; } default: throw new ProtoException("Unexpected wire-type: " + source.WireType.ToString()); } Label_0115: throw new ProtoException("Unknown min/max value: " + num2.ToString()); }
public static object ReadNetObject(object value, ProtoReader source, int key, Type type, NetObjectOptions options) { int num; SubItemToken token = ProtoReader.StartSubItem(source); int newObjectKey = -1; int num3 = -1; while ((num = source.ReadFieldHeader()) > 0) { int num4; bool flag; bool flag2; bool flag3; object keyedObject; switch (num) { case 1: { num4 = source.ReadInt32(); value = source.NetCache.GetKeyedObject(num4); continue; } case 2: { newObjectKey = source.ReadInt32(); continue; } case 3: { num4 = source.ReadInt32(); type = (Type)source.NetCache.GetKeyedObject(num4); key = source.GetTypeKey(ref type); continue; } case 4: { num3 = source.ReadInt32(); continue; } case 8: { string str = source.ReadString(); type = source.DeserializeType(str); if (type == null) { throw new ProtoException("Unable to resolve type: " + str + " (you can use the TypeModel.DynamicTypeFormatting event to provide a custom mapping)"); } break; } case 10: flag = type == typeof(string); flag2 = value == null; flag3 = flag2 && (flag || (((byte)(options & NetObjectOptions.LateSet)) != 0)); if ((newObjectKey < 0) || flag3) { goto Label_0180; } if (value != null) { goto Label_0162; } source.TrapNextObject(newObjectKey); goto Label_016F; default: goto Label_020D; } if (type == typeof(string)) { key = -1; continue; } key = source.GetTypeKey(ref type); if (key >= 0) { continue; } throw new InvalidOperationException("Dynamic type is not a contract-type: " + type.Name); Label_0162: source.NetCache.SetKeyedObject(newObjectKey, value); Label_016F: if (num3 >= 0) { source.NetCache.SetKeyedObject(num3, type); } Label_0180: keyedObject = value; if (flag) { value = source.ReadString(); } else { value = ProtoReader.ReadTypedObject(keyedObject, key, source, type); } if (newObjectKey >= 0) { if (flag2 && !flag3) { keyedObject = source.NetCache.GetKeyedObject(newObjectKey); } if (flag3) { source.NetCache.SetKeyedObject(newObjectKey, value); if (num3 >= 0) { source.NetCache.SetKeyedObject(num3, type); } } } if (((newObjectKey >= 0) && !flag3) && !object.ReferenceEquals(keyedObject, value)) { throw new ProtoException("A reference-tracked object changed reference during deserialization"); } if ((newObjectKey < 0) && (num3 >= 0)) { source.NetCache.SetKeyedObject(num3, type); } continue; Label_020D: source.SkipField(); } if ((newObjectKey >= 0) && (((byte)(options & NetObjectOptions.AsReference)) == 0)) { throw new ProtoException("Object key in input stream, but reference-tracking was not expected"); } ProtoReader.EndSubItem(token, source); return(value); }