public object Read(object value, ProtoReader source) { Helpers.DebugAssert(value == null); // since replaces int wireValue = source.ReadInt32(); if(map == null) { return WireToEnum(wireValue); } for(int i = 0 ; i < map.Length ; i++) { if(map[i].WireValue == wireValue) { return map[i].Value; } } source.ThrowEnumException(ExpectedType, wireValue); return null; // to make compiler happy }
public object Read(ProtoReader source, ref ProtoReader.State state, object value) { Helpers.DebugAssert(value == null); // since replaces int wireValue = source.ReadInt32(ref state); if (map == null) { return(WireToEnum(wireValue)); } for (int i = 0; i < map.Length; i++) { if (map[i].WireValue == wireValue) { return(map[i].TypedValue); } } source.ThrowEnumException(ref state, ExpectedType, wireValue); return(null); // to make compiler happy }
/// <summary> /// The read. /// </summary> /// <param name="targetPlatform"> /// The target platform. /// </param> /// <param name="protoReader"> /// The proto reader. /// </param> /// <returns> /// The <see cref="TargetPlatform"/>. /// </returns> private static TargetPlatform Read(TargetPlatform targetPlatform, ProtoReader protoReader) { int num = protoReader.ReadInt32(); var result = TargetPlatform.Windows; if (num != 0) { if (num != 1) { if (num != 2) { if (num != 3) { if (num != 4) { if (num != 5) { if (num != 6) { if (num != 7) { if (num != 8) { if (num != 9) { if (num != 10) { if (num != 11) { if (num != 12) { protoReader.ThrowEnumException( typeof(TargetPlatform), num); } else { result = TargetPlatform.RaspberryPi; } } else { result = TargetPlatform.WindowsPhone8; } } else { result = TargetPlatform.PlayStationMobile; } } else { result = TargetPlatform.Ouya; } } else { result = TargetPlatform.NativeClient; } } else { result = TargetPlatform.WindowsStoreApp; } } else { result = TargetPlatform.MacOSX; } } else { result = TargetPlatform.Linux; } } else { result = TargetPlatform.Android; } } else { result = TargetPlatform.iOS; } } else { result = TargetPlatform.WindowsPhone; } } else { result = TargetPlatform.Xbox360; } } else { result = TargetPlatform.Windows; } return(result); }
/// <summary> /// The read. /// </summary> /// <param name="platformData"> /// The platform data. /// </param> /// <param name="protoReader"> /// The proto reader. /// </param> /// <returns> /// The <see cref="PlatformData"/>. /// </returns> private static PlatformData Read(PlatformData platformData, ProtoReader protoReader) { int num; while ((num = protoReader.ReadFieldHeader()) > 0) { if (num != 1) { if (num != 2) { if (platformData == null) { var expr_164 = new PlatformData(); ProtoReader.NoteObject(expr_164, protoReader); platformData = expr_164; } protoReader.SkipField(); } else { if (platformData == null) { var expr_134 = new PlatformData(); ProtoReader.NoteObject(expr_134, protoReader); platformData = expr_134; } byte[] array = ProtoReader.AppendBytes(platformData.Data, protoReader); if (array != null) { platformData.Data = array; } } } else { if (platformData == null) { var expr_19 = new PlatformData(); ProtoReader.NoteObject(expr_19, protoReader); platformData = expr_19; } int num2 = protoReader.ReadInt32(); var targetPlatform = TargetPlatform.Windows; if (num2 != 0) { if (num2 != 1) { if (num2 != 2) { if (num2 != 3) { if (num2 != 4) { if (num2 != 5) { if (num2 != 6) { if (num2 != 7) { if (num2 != 8) { if (num2 != 9) { if (num2 != 10) { if (num2 != 11) { if (num2 != 12) { protoReader.ThrowEnumException( typeof(TargetPlatform), num2); } else { targetPlatform = TargetPlatform.RaspberryPi; } } else { targetPlatform = TargetPlatform.WindowsPhone8; } } else { targetPlatform = TargetPlatform.PlayStationMobile; } } else { targetPlatform = TargetPlatform.Ouya; } } else { targetPlatform = TargetPlatform.NativeClient; } } else { targetPlatform = TargetPlatform.WindowsStoreApp; } } else { targetPlatform = TargetPlatform.MacOSX; } } else { targetPlatform = TargetPlatform.Linux; } } else { targetPlatform = TargetPlatform.Android; } } else { targetPlatform = TargetPlatform.iOS; } } else { targetPlatform = TargetPlatform.WindowsPhone; } } else { targetPlatform = TargetPlatform.Xbox360; } } else { targetPlatform = TargetPlatform.Windows; } platformData.Platform = targetPlatform; } } if (platformData == null) { var expr_18C = new PlatformData(); ProtoReader.NoteObject(expr_18C, protoReader); platformData = expr_18C; } return(platformData); }
public object Read(object value, ProtoReader source) { int num = source.ReadInt32(); if (this.map == null) { return this.WireToEnum(num); } for (int i = 0; i < this.map.Length; i++) { if (this.map[i].WireValue == num) { return this.map[i].TypedValue; } } source.ThrowEnumException(this.ExpectedType, num); return null; }