public MavLink4Net.Messages.IMessage Deserialize(System.IO.BinaryReader reader) { MavLink4Net.Messages.Common.HighLatencyMessage message = new MavLink4Net.Messages.Common.HighLatencyMessage(); message.CustomMode = reader.ReadUInt32(); message.Latitude = reader.ReadInt32(); message.Longitude = reader.ReadInt32(); message.Roll = reader.ReadInt16(); message.Pitch = reader.ReadInt16(); message.Heading = reader.ReadUInt16(); message.HeadingSp = reader.ReadInt16(); message.AltitudeAmsl = reader.ReadInt16(); message.AltitudeSp = reader.ReadInt16(); message.WpDistance = reader.ReadUInt16(); message.BaseMode = ((MavLink4Net.Messages.Common.ModeFlag)(reader.ReadByte())); message.LandedState = ((MavLink4Net.Messages.Common.LandedState)(reader.ReadByte())); message.Throttle = reader.ReadSByte(); message.Airspeed = reader.ReadByte(); message.AirspeedSp = reader.ReadByte(); message.Groundspeed = reader.ReadByte(); message.ClimbRate = reader.ReadSByte(); message.GpsNsat = reader.ReadByte(); message.GpsFixType = ((MavLink4Net.Messages.Common.GpsFixType)(reader.ReadByte())); message.BatteryRemaining = reader.ReadByte(); message.Temperature = reader.ReadSByte(); message.TemperatureAir = reader.ReadSByte(); message.Failsafe = reader.ReadByte(); message.WpNum = reader.ReadByte(); return(message); }
internal void BinaryReaderRead(System.IO.BinaryReader br) { IsAnimated = br.ReadSByte(); AnimationFrameCount = br.ReadInt16(); PauseFrameCount = br.ReadInt16(); Interval = br.ReadSingle(); PauseAfterLoop = br.ReadSingle(); Frame = br.ReadInt16(); DrawFrame = br.ReadInt16(); AnimateLast = br.ReadSingle(); HasFrameChanged = br.ReadSByte(); Drawn = br.ReadSByte(); }
// Converts an array of one byte to an unsigned byte public static SByte To_B(byte [] bytes) { in_bytes.reset(); in_bytes.set_stream_bytes(bytes); return(in_stream.ReadSByte()); }
public void Initialize(System.IO.BinaryReader br) { int nodes; int address; int loop = 0; br.BaseStream.Position = PathListAddress; do { nodes = br.ReadSByte(); br.BaseStream.Position += 3; address = br.ReadBigInt32(); if (nodes <= 0 || loop >= 50 || ((address >> 16) & 0xFFC0) //assuming an address range of 0200 0000 to 022F FFFF, quite larger than expected != (((int)ORom.Bank.scene) << 8)) // { break; } var t = br.BaseStream.Position; Paths.Add(new Path(nodes, address & 0xFFFFFF, br)); br.BaseStream.Position = t; loop++; }while (true); }
public static object ReadAs(System.IO.Stream stream, Type type) { System.IO.BinaryReader reader = new System.IO.BinaryReader(stream); if (type == typeof(bool)) { return(reader.ReadBoolean()); } else if (type == typeof(char)) { return(reader.ReadChar()); } else if (type == typeof(byte)) { return(reader.ReadByte()); } else if (type == typeof(short)) { return(reader.ReadInt16()); } else if (type == typeof(int)) { return(reader.ReadInt32()); } else if (type == typeof(long)) { return(reader.ReadInt64()); } else if (type == typeof(float)) { return(reader.ReadSingle()); } else if (type == typeof(double)) { return(reader.ReadDouble()); } else if (type == typeof(sbyte)) { return(reader.ReadSByte()); } else if (type == typeof(ushort)) { return(reader.ReadUInt16()); } else if (type == typeof(uint)) { return(reader.ReadUInt32()); } else if (type == typeof(ulong)) { return(reader.ReadUInt64()); } else if (type == typeof(string)) { return(reader.ReadString()); } throw new ArgumentException("Usupported type!"); }
public void ReadData(System.IO.BinaryReader stream) { for (var z = 0; z < depth; z += 1) { for (var x = 0; x < width; x += 1) { heightMap[x, z] = stream.ReadSByte(); } } version += 1; }
public void FromBinary(System.IO.BinaryReader reader) { timestamp_us = (ulong)IPAddress.NetworkToHostOrder(reader.ReadInt64()); bssid = reader.ReadBytes(BSSID_LENGTH); byte[] ssid_bytes = reader.ReadBytes(SSID_LENGTH_WITH0_MAX); signal_dbm = reader.ReadSByte(); rx_packets = (uint)IPAddress.NetworkToHostOrder(reader.ReadInt32()); tx_packets = (uint)IPAddress.NetworkToHostOrder(reader.ReadInt32()); bssid_string = BSSIDToString(bssid); ssid = FromASCII(ssid_bytes); }
public void Restore(System.IO.BinaryReader r) { Repeat = new RepeatCount(r.ReadInt32()); mStep = (EStep)r.ReadSByte(); int length = r.ReadInt32(); byte[] data = r.ReadBytes(length); mVarMgr = VariableMgr.Import(data); mAction.Restore(r); }
public void Restore(System.IO.BinaryReader r) { Result = (EResult)r.ReadSByte(); int length = r.ReadInt32(); byte[] data = r.ReadBytes(length); mVarMgr = VariableMgr.Import(data); mTriggerGroup.Restore(r); }
public MavLink4Net.Messages.IMessage Deserialize(System.IO.BinaryReader reader) { MavLink4Net.Messages.Common.HighLatency2Message message = new MavLink4Net.Messages.Common.HighLatency2Message(); message.Timestamp = reader.ReadUInt32(); message.Latitude = reader.ReadInt32(); message.Longitude = reader.ReadInt32(); message.CustomMode = reader.ReadUInt16(); message.Altitude = reader.ReadInt16(); message.TargetAltitude = reader.ReadInt16(); message.TargetDistance = reader.ReadUInt16(); message.WpNum = reader.ReadUInt16(); message.FailureFlags = ((MavLink4Net.Messages.Common.HlFailureFlag)(reader.ReadUInt16())); message.Type = ((MavLink4Net.Messages.Common.Type)(reader.ReadByte())); message.Autopilot = ((MavLink4Net.Messages.Common.Autopilot)(reader.ReadByte())); message.Heading = reader.ReadByte(); message.TargetHeading = reader.ReadByte(); message.Throttle = reader.ReadByte(); message.Airspeed = reader.ReadByte(); message.AirspeedSp = reader.ReadByte(); message.Groundspeed = reader.ReadByte(); message.Windspeed = reader.ReadByte(); message.WindHeading = reader.ReadByte(); message.Eph = reader.ReadByte(); message.Epv = reader.ReadByte(); message.TemperatureAir = reader.ReadSByte(); message.ClimbRate = reader.ReadSByte(); message.Battery = reader.ReadSByte(); message.Custom0 = reader.ReadSByte(); message.Custom1 = reader.ReadSByte(); message.Custom2 = reader.ReadSByte(); return(message); }
static StackObject *ReadSByte_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.IO.BinaryReader instance_of_this_method = (System.IO.BinaryReader) typeof(System.IO.BinaryReader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.ReadSByte(); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
public MavLink4Net.Messages.IMessage Deserialize(System.IO.BinaryReader reader) { MavLink4Net.Messages.Common.SysStatusMessage message = new MavLink4Net.Messages.Common.SysStatusMessage(); message.OnboardControlSensorsPresent = ((MavLink4Net.Messages.Common.SysStatusSensor)(reader.ReadUInt32())); message.OnboardControlSensorsEnabled = ((MavLink4Net.Messages.Common.SysStatusSensor)(reader.ReadUInt32())); message.OnboardControlSensorsHealth = ((MavLink4Net.Messages.Common.SysStatusSensor)(reader.ReadUInt32())); message.Load = reader.ReadUInt16(); message.VoltageBattery = reader.ReadUInt16(); message.CurrentBattery = reader.ReadInt16(); message.DropRateComm = reader.ReadUInt16(); message.ErrorsComm = reader.ReadUInt16(); message.ErrorsCount1 = reader.ReadUInt16(); message.ErrorsCount2 = reader.ReadUInt16(); message.ErrorsCount3 = reader.ReadUInt16(); message.ErrorsCount4 = reader.ReadUInt16(); message.BatteryRemaining = reader.ReadSByte(); return(message); }
static int _m_ReadSByte(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); System.IO.BinaryReader gen_to_be_invoked = (System.IO.BinaryReader)translator.FastGetCSObj(L, 1); { sbyte gen_ret = gen_to_be_invoked.ReadSByte( ); LuaAPI.xlua_pushinteger(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public MavLink4Net.Messages.IMessage Deserialize(System.IO.BinaryReader reader) { MavLink4Net.Messages.Common.BatteryStatusMessage message = new MavLink4Net.Messages.Common.BatteryStatusMessage(); message.CurrentConsumed = reader.ReadInt32(); message.EnergyConsumed = reader.ReadInt32(); message.Temperature = reader.ReadInt16(); message.Voltages[0] = reader.ReadUInt16(); message.Voltages[1] = reader.ReadUInt16(); message.Voltages[2] = reader.ReadUInt16(); message.Voltages[3] = reader.ReadUInt16(); message.Voltages[4] = reader.ReadUInt16(); message.Voltages[5] = reader.ReadUInt16(); message.Voltages[6] = reader.ReadUInt16(); message.Voltages[7] = reader.ReadUInt16(); message.Voltages[8] = reader.ReadUInt16(); message.Voltages[9] = reader.ReadUInt16(); message.CurrentBattery = reader.ReadInt16(); message.Id = reader.ReadByte(); message.BatteryFunction = ((MavLink4Net.Messages.Common.BatteryFunction)(reader.ReadByte())); message.Type = ((MavLink4Net.Messages.Common.BatteryType)(reader.ReadByte())); message.BatteryRemaining = reader.ReadSByte(); return(message); }
public static Row Deserialize(byte[] bytes) { using (System.IO.MemoryStream MS = new System.IO.MemoryStream(bytes, false)) { using (System.IO.BinaryReader BR = new System.IO.BinaryReader(MS)) { byte[] columnSet = BR.ReadBytes(32); int FieldCount = BR.ReadInt32(); object[] fields = new object[FieldCount]; ColumnSet cs = css [columnSet]; if (cs.Columns.Length != fields.Length) { throw new Exception(); } for (int n = 0; n != fields.Length; n++) { bool Null = BR.ReadBoolean(); if (Null) { fields [n] = null; continue; } switch (cs.Columns [n].TFQN) { case "System.Byte[]": fields [n] = BR.ReadBytes(BR.ReadInt32()); break; case "System.Byte": fields [n] = BR.ReadByte(); break; case "System.SByte": fields [n] = BR.ReadSByte(); break; case "System.Int16": fields [n] = BR.ReadInt16(); break; case "System.UInt16": fields [n] = BR.ReadUInt16(); break; case "System.Int32": fields [n] = BR.ReadInt32(); break; case "System.UInt32": fields [n] = BR.ReadUInt32(); break; case "System.Int64": fields [n] = BR.ReadInt64(); break; case "System.UInt64": fields [n] = BR.ReadUInt64(); break; case "System.Single": fields [n] = BR.ReadSingle(); break; case "System.Double": fields [n] = BR.ReadDouble(); break; case "System.String": fields [n] = BR.ReadString(); break; case "System.Char": fields [n] = BR.ReadChar(); break; case "System.Boolean": fields [n] = BR.ReadBoolean(); break; case "System.DateTime": fields [n] = new DateTime(BR.ReadInt64()); break; case "System.Guid": fields [n] = new Guid(BR.ReadBytes(16)); break; } } return(new Row(cs, fields)); } } }
public Int32 ReadBoolean(ref Boolean value) { if ((mStream == null) || (mReader == null) || ((mStream.Length - mStream.Position) < (sizeof(Boolean)) + 1)) { return(AResult.AE_FAIL); } mReader.ReadSByte(); value = mReader.ReadBoolean(); return(AResult.AS_OK); }
public MavLink4Net.Messages.IMessage Deserialize(System.IO.BinaryReader reader) { MavLink4Net.Messages.Common.MemoryVectMessage message = new MavLink4Net.Messages.Common.MemoryVectMessage(); message.Address = reader.ReadUInt16(); message.Ver = reader.ReadByte(); message.Type = reader.ReadByte(); message.Value[0] = reader.ReadSByte(); message.Value[1] = reader.ReadSByte(); message.Value[2] = reader.ReadSByte(); message.Value[3] = reader.ReadSByte(); message.Value[4] = reader.ReadSByte(); message.Value[5] = reader.ReadSByte(); message.Value[6] = reader.ReadSByte(); message.Value[7] = reader.ReadSByte(); message.Value[8] = reader.ReadSByte(); message.Value[9] = reader.ReadSByte(); message.Value[10] = reader.ReadSByte(); message.Value[11] = reader.ReadSByte(); message.Value[12] = reader.ReadSByte(); message.Value[13] = reader.ReadSByte(); message.Value[14] = reader.ReadSByte(); message.Value[15] = reader.ReadSByte(); message.Value[16] = reader.ReadSByte(); message.Value[17] = reader.ReadSByte(); message.Value[18] = reader.ReadSByte(); message.Value[19] = reader.ReadSByte(); message.Value[20] = reader.ReadSByte(); message.Value[21] = reader.ReadSByte(); message.Value[22] = reader.ReadSByte(); message.Value[23] = reader.ReadSByte(); message.Value[24] = reader.ReadSByte(); message.Value[25] = reader.ReadSByte(); message.Value[26] = reader.ReadSByte(); message.Value[27] = reader.ReadSByte(); message.Value[28] = reader.ReadSByte(); message.Value[29] = reader.ReadSByte(); message.Value[30] = reader.ReadSByte(); message.Value[31] = reader.ReadSByte(); return(message); }
public bool Load(System.IO.BinaryReader r) { int sampleCt = 15; long startPos = r.BaseStream.Position; r.BaseStream.Seek(startPos + 1080, System.IO.SeekOrigin.Begin); string mkTag = GetByteArrayString(r, 4); r.BaseStream.Seek(startPos, System.IO.SeekOrigin.Begin); switch (mkTag) { case "M.K.": sampleCt = 31; break; case "M!K!": break; case "FLT4": break; case "FLT8": this.channelsCt = 8; break; case "4CHN": break; case "6CHN": channelsCt = 6; break; case "8CHN": channelsCt = 8; break; } this.title = GetByteArrayString(r, 20); for (int i = 0; i < sampleCt; ++i) { Sample s = new Sample(); s.name = GetByteArrayString(r, 22); s.length = ReadUShort(r) * 2; int finet = r.ReadByte(); s.finetune = NibbleToFinetune(finet); byte vol = r.ReadByte(); s.defaultVolume = vol; s.loopBack = ReadUShort(r) * 2; s.loopLength = ReadUShort(r) * 2; if (s.loopLength <= 2) { s.loopLength = 0; } this.samples.Add(s); } int patternCt = r.ReadByte(); this.restartPos = r.ReadByte(); this.sequences = r.ReadBytes(patternCt); if (patternCt != 128) { r.ReadBytes(128 - patternCt); // Consume the rest of the unneeded 128 } // We already read this at the beginning to figure out sampleCt. // Now we're just moving past it to read our binary reader properly // aligned. r.ReadBytes(4); int highestPatternIdx = -1; for (int i = 0; i < this.sequences.Length; ++i) { highestPatternIdx = Mathf.Max(highestPatternIdx, this.sequences[i]); } for (int i = 0; i < highestPatternIdx + 1; ++i) { Pattern p = new Pattern(); p.channels = new Channel[channelsCt]; patternData.Add(p); for (int c = 0; c < channelsCt; ++c) { p.channels[c] = new Channel(); p.channels[c].divs = new Div[64]; } for (int j = 0; j < 64 * channelsCt; ++j) { int n = j / channelsCt; int c = j % channelsCt; byte [] rbd = r.ReadBytes(4); int sample = (rbd[0] & hiNibble) | ((rbd[2] & hiNibble) >> 4); int period = ((rbd[0] & loNibble) << 8) | rbd[1]; int effect = ((rbd[2] & loNibble) << 8) | rbd[3]; Div note = new Div(); note.sampleIdx = sample - 1; // Rebase it so the ids are array indices and -1 is the non-instrument instead of 0 note.period = period; note.effectCommand = effect; p.channels[c].divs[n] = note; } } for (int i = 0; i < sampleCt; ++i) { int sCt = Mathf.Max(0, samples[i].length); samples[i].pcm = new float[sCt]; for (int s = 0; s < samples[i].pcm.Length; ++s) { samples[i].pcm[s] = (float)r.ReadSByte() / 128.0f; } // The first two have some weird deal where they're the audio // data as well as this other thing if (samples[i].pcm.Length >= 2) { samples[i].pcm[0] = 0.0f; samples[i].pcm[1] = 0.0f; } } return(true); }
protected internal void BinaryReaderRead(System.IO.BinaryReader br) { Type = br.ReadByte(); var nameLength = br.ReadUInt16(); Id = br.ReadInt16(); LanguageDllIdName = br.ReadUInt16(); LanguageDllIdCreate = br.ReadUInt16(); UnitClass = br.ReadInt16(); StandingGraphic0 = br.ReadInt16(); StandingGraphic1 = br.ReadInt16(); DyingGraphic = br.ReadInt16(); UndeadGraphic = br.ReadInt16(); UndeadMode = br.ReadSByte(); HitPoints = br.ReadInt16(); LineOfSight = br.ReadSingle(); GarrisonCapacity = br.ReadSByte(); CollisionSizeX = br.ReadSingle(); CollisionSizeY = br.ReadSingle(); CollisionSizeZ = br.ReadSingle(); TrainSound = br.ReadInt16(); DamageSound = br.ReadInt16(); DeadUnitId = br.ReadInt16(); SortNumber = br.ReadSByte(); CanBeBuiltOn = br.ReadSByte(); IconId = br.ReadInt16(); HideInEditor = br.ReadSByte(); OldPortraitPict = br.ReadInt16(); Enabled = br.ReadByte(); Disabled = br.ReadByte(); PlacementSideTerrain0 = br.ReadInt16(); PlacementSideTerrain1 = br.ReadInt16(); PlacementTerrain0 = br.ReadInt16(); PlacementTerrain1 = br.ReadInt16(); ClearanceSizeX = br.ReadSingle(); ClearanceSizeY = br.ReadSingle(); HillMode = br.ReadByte(); FogVisibility = br.ReadByte(); TerrainRestriction = br.ReadInt16(); FlyMode = br.ReadByte(); ResourceCapacity = br.ReadInt16(); ResourceDecay = br.ReadSingle(); BlastDefenseLevel = br.ReadByte(); CombatLevel = br.ReadByte(); InteractionMode = br.ReadByte(); MinimapMode = br.ReadByte(); InterfaceKind = br.ReadByte(); MultipleAttributeMode = br.ReadSingle(); MinimapColor = br.ReadByte(); LanguageDllIdHelp = br.ReadInt32(); LanguageDllIdHotKeyText = br.ReadInt32(); HotKey = br.ReadInt32(); Recyclable = br.ReadByte(); EnableAutoGather = br.ReadByte(); CreateDoppelgangerOnDeath = br.ReadByte(); ResourceGatherGroup = br.ReadByte(); OcclusionMode = br.ReadSByte(); ObstructionType = br.ReadByte(); ObstructionClass = br.ReadByte(); Trait = br.ReadByte(); Civilization = br.ReadByte(); Nothing = br.ReadInt16(); SelectionEffect = br.ReadByte(); EditorSelectionColor = br.ReadByte(); OutlineSizeX = br.ReadSingle(); OutlineSizeY = br.ReadSingle(); OutlineSizeZ = br.ReadSingle(); Storage1Id = br.ReadInt16(); Storage1Amount = br.ReadSingle(); Storage1Mode = br.ReadByte(); Storage2Id = br.ReadInt16(); Storage2Amount = br.ReadSingle(); Storage2Mode = br.ReadByte(); Storage3Id = br.ReadInt16(); Storage3Amount = br.ReadSingle(); Storage3Mode = br.ReadByte(); var nDamageGraphics = br.ReadByte(); DamageGraphics = new List <DamageGraphic>(nDamageGraphics); for (var i = 0; i < nDamageGraphics; i++) { var dg = new DamageGraphic(); DamageGraphics.Add(dg); dg.GraphicId = br.ReadInt16(); dg.DamagePercent = br.ReadByte(); dg.OldApplyMode = br.ReadByte(); dg.ApplyMode = br.ReadByte(); } SelectionSound = br.ReadInt16(); DyingSound = br.ReadInt16(); OldAttackReaction = br.ReadByte(); ConvertTerrain = br.ReadByte(); Name = br.ReadBytes(nameLength); CopyId = br.ReadInt16(); BaseId = br.ReadInt16(); if (Type >= 20) { Speed = br.ReadSingle(); } if (Type >= 30) { WalkingGraphic = br.ReadInt16(); RunnngGraphic = br.ReadInt16(); RotationSpeed = br.ReadSingle(); OldSizeClass = br.ReadByte(); TrackingUnitId = br.ReadInt16(); TrackingUnitMode = br.ReadByte(); TrackingUnitDensity = br.ReadSingle(); OldMoveAlgorithm = br.ReadByte(); TurnRadius = br.ReadSingle(); TurnRadiusSpeed = br.ReadSingle(); MaxYawPerSecondMoving = br.ReadSingle(); StationaryYawRevolutionTime = br.ReadSingle(); MaxYawPerSecondStationary = br.ReadSingle(); } if (Type >= 40) { DefaultTaskId = br.ReadInt16(); SearchRadius = br.ReadSingle(); WorkRate = br.ReadSingle(); DropSite0 = br.ReadInt16(); DropSite1 = br.ReadInt16(); TaskSwapGroup = br.ReadByte(); AttackSoundId = br.ReadInt16(); MoveSoundId = br.ReadInt16(); RunPattern = br.ReadByte(); } if (Type >= 50) { BaseArmor = br.ReadInt16(); var nAttacks = br.ReadUInt16(); Attacks = new List <AttackArmor>(nAttacks); for (var i = 0; i < nAttacks; i++) { var a = new AttackArmor(); Attacks.Add(a); a.Id = br.ReadInt16(); a.Amount = br.ReadInt16(); } var nDefenses = br.ReadUInt16(); Armors = new List <AttackArmor>(nDefenses); for (var i = 0; i < nDefenses; i++) { var d = new AttackArmor(); Armors.Add(d); d.Id = br.ReadInt16(); d.Amount = br.ReadInt16(); } DefenseTerrainBonus = br.ReadInt16(); MaxRange = br.ReadSingle(); BlastWidth = br.ReadSingle(); ReloadTime = br.ReadSingle(); ProjectileUnitId = br.ReadInt16(); AccuracyPercent = br.ReadInt16(); BreakOffCombat = br.ReadByte(); FrameDelay = br.ReadInt16(); GraphicDisplacementX = br.ReadSingle(); GraphicDisplacementY = br.ReadSingle(); GraphicDisplacementZ = br.ReadSingle(); BlastAttackLevel = br.ReadByte(); MinRange = br.ReadSingle(); AccuracyDispersion = br.ReadSingle(); AttackGraphic = br.ReadInt16(); DisplayedMeleeArmor = br.ReadInt16(); DisplayedAttack = br.ReadInt16(); DisplayedRange = br.ReadSingle(); DisplayedReloadTime = br.ReadSingle(); } if (Type == 60) { ProjectileType = br.ReadByte(); SmartMode = br.ReadByte(); HitMode = br.ReadByte(); VanishMode = br.ReadByte(); AreaEffectSpecials = br.ReadByte(); ProjectileArc = br.ReadSingle(); } if (Type >= 70) { Cost1Id = br.ReadInt16(); Cost1Amount = br.ReadInt16(); Cost1Used = br.ReadInt16(); Cost2Id = br.ReadInt16(); Cost2Amount = br.ReadInt16(); Cost2Used = br.ReadInt16(); Cost3Id = br.ReadInt16(); Cost3Amount = br.ReadInt16(); Cost3Used = br.ReadInt16(); TrainTime = br.ReadInt16(); TrainLocationId = br.ReadInt16(); ButtonId = br.ReadByte(); RearAttackModifier = br.ReadSingle(); FlankAttackModifier = br.ReadSingle(); CreatableType = br.ReadByte(); HeroMode = br.ReadByte(); GarrisonGraphic = br.ReadInt32(); TotalProjectiles = br.ReadSingle(); MaxTotalProjectiles = br.ReadByte(); ProjectileSpawningAreaWidth = br.ReadSingle(); ProjectileSpawningAreaLength = br.ReadSingle(); ProjectileSpawningAreaRandomness = br.ReadSingle(); SecondaryProjectileId = br.ReadInt32(); SpecialGraphicId = br.ReadInt32(); SpecialAbility = br.ReadByte(); DisplayedPierceArmor = br.ReadInt16(); } if (Type == 80) { ConstructionGraphicId = br.ReadInt16(); SnowGraphicId = br.ReadInt16(); AdjacentMode = br.ReadByte(); GraphicsAngle = br.ReadInt16(); DisappearsWhenBuilt = br.ReadByte(); StackUnitId = br.ReadInt16(); FoundationTerrainId = br.ReadInt16(); OldOverlayId = br.ReadInt16(); TechId = br.ReadInt16(); CanBurn = br.ReadByte(); Annex1Id = br.ReadInt16(); Annex1Misplacement0 = br.ReadSingle(); Annex1Misplacement1 = br.ReadSingle(); Annex2Id = br.ReadInt16(); Annex2Misplacement0 = br.ReadSingle(); Annex2Misplacement1 = br.ReadSingle(); Annex3Id = br.ReadInt16(); Annex3Misplacement0 = br.ReadSingle(); Annex3Misplacement1 = br.ReadSingle(); Annex4Id = br.ReadInt16(); Annex4Misplacement0 = br.ReadSingle(); Annex4Misplacement1 = br.ReadSingle(); HeadUnitId = br.ReadInt16(); TransformUnitId = br.ReadInt16(); TransformSound = br.ReadInt16(); ConstructionSoundId = br.ReadInt16(); GarrisonType = br.ReadByte(); GarrisonHealRate = br.ReadSingle(); GarrisonRepairRate = br.ReadSingle(); PileUnit = br.ReadInt16(); LootingTable = br.ReadBytes(6); } }
/// <summary> /// Processes the Sniffer packet capture global header /// </summary> /// <param name="theBinaryReader">The object that provides for binary reading from the packet capture</param> /// <returns>Boolean flag that indicates whether the Sniffer packet capture global header could be processed</returns> protected override bool ProcessPacketCaptureGlobalHeader(System.IO.BinaryReader theBinaryReader) { bool theResult = true; if (theBinaryReader == null) { throw new System.ArgumentNullException("theBinaryReader"); } // Just read off the data for the Sniffer packet capture global header from the packet capture so we can move on // Some of the data will be stored for use below ulong theMagicNumberHigh = theBinaryReader.ReadUInt64(); ulong theMagicNumberLow = theBinaryReader.ReadUInt64(); byte theMagicNumberTerminator = theBinaryReader.ReadByte(); ushort theRecordType = theBinaryReader.ReadUInt16(); theBinaryReader.ReadUInt32(); // Record length short theVersionMajor = theBinaryReader.ReadInt16(); short theVersionMinor = theBinaryReader.ReadInt16(); theBinaryReader.ReadInt16(); // Time theBinaryReader.ReadInt16(); // Date sbyte theType = theBinaryReader.ReadSByte(); byte theNetworkEncapsulationType = theBinaryReader.ReadByte(); sbyte theFormatVersion = theBinaryReader.ReadSByte(); byte theTimestampUnits = theBinaryReader.ReadByte(); theBinaryReader.ReadSByte(); // Compression version theBinaryReader.ReadSByte(); // Compression level theBinaryReader.ReadInt32(); // Reserved // Validate fields from the Sniffer packet capture global header theResult = this.ValidateGlobalHeader( theMagicNumberHigh, theMagicNumberLow, theMagicNumberTerminator, theRecordType, theVersionMajor, theVersionMinor, theType, theNetworkEncapsulationType, theFormatVersion); if (theResult) { // Set up the value for the network data link type this.PacketCaptureNetworkDataLinkType = theNetworkEncapsulationType; double thePacketCaptureTimestampAccuracy = 0.0; // Derive the value for the timestamp accuracy (actually a timestamp slice for a Sniffer packet capture) from the timestamp units in the Sniffer packet capture global header theResult = this.CalculateTimestampAccuracy( theTimestampUnits, out thePacketCaptureTimestampAccuracy); // Set up the value for the timestamp accuracy this.PacketCaptureTimestampAccuracy = thePacketCaptureTimestampAccuracy; } return(theResult); }
public void read(System.IO.BinaryReader reader) { if (count <= 0) { return; } switch (type) { case TIFFdataType.Byte: content = new byte[count]; for (int i = 0; i < count; i++) { ((byte[])content)[i] = reader.ReadByte(); } break; case TIFFdataType.Ascii: content = new char[count]; for (int i = 0; i < count; i++) { ((char[])content)[i] = (char)reader.ReadByte(); } break; case TIFFdataType.Short: content = new ushort[count]; for (int i = 0; i < count; i++) { ((ushort[])content)[i] = reader.ReadUInt16(); } break; case TIFFdataType.Long: content = new uint[count]; for (int i = 0; i < count; i++) { ((uint[])content)[i] = reader.ReadUInt32(); } break; case TIFFdataType.Rational: content = new uint[count * 2]; for (int i = 0; i < 2 * count; i++) { ((uint[])content)[i] = reader.ReadUInt32(); } break; case TIFFdataType.SignedByte: content = new sbyte[count]; for (int i = 0; i < count; i++) { ((sbyte[])content)[i] = reader.ReadSByte(); } break; case TIFFdataType.SignedShort: content = new short[count]; for (int i = 0; i < count; i++) { ((short[])content)[i] = reader.ReadInt16(); } break; case TIFFdataType.SignedLong: content = new int[count]; for (int i = 0; i < count; i++) { ((int[])content)[i] = reader.ReadInt32(); } break; case TIFFdataType.SignedRational: content = new int[count * 2]; for (int i = 0; i < 2 * count; i++) { ((int[])content)[i] = reader.ReadInt32(); } break; case TIFFdataType.Float: content = new float[count]; for (int i = 0; i < count; i++) { ((float[])content)[i] = reader.ReadSingle(); } break; case TIFFdataType.Double: content = new double[count]; for (int i = 0; i < count; i++) { ((double[])content)[i] = reader.ReadDouble(); } break; default: content = new Object[0]; break; } }
public override object Deserialize(System.IO.BinaryReader binaryReader) { bool hasValue = binaryReader.ReadBoolean(); if (!hasValue) { return(null); } int typeID = binaryReader.ReadByte(); switch (typeID) { case 1: return(binaryReader.ReadBoolean()); case 2: return(binaryReader.ReadByte()); case 128: return(binaryReader.ReadSByte()); case 3: return(binaryReader.ReadInt16()); case 129: return(binaryReader.ReadUInt16()); case 4: return(binaryReader.ReadInt32()); case 130: return(binaryReader.ReadUInt32()); case 5: return(binaryReader.ReadInt64()); case 131: return(binaryReader.ReadUInt64()); case 9: return(binaryReader.ReadDouble()); case 16: return(binaryReader.ReadString()); case 144: return(binaryReader.ReadChar()); case 24: return(new DateTime(binaryReader.ReadInt64())); case 32: return(new Guid(binaryReader.ReadBytes(16))); case 36: return(binaryReader.ReadBytes(binaryReader.ReadInt32())); default: throw new Exception(string.Format("Serialization for type <{0}> is not supported", typeID)); } }
public static Row Deserialize(byte[] bytes) { using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) { using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) { byte[] columnSet = BR.ReadBytes (32); int FieldCount = BR.ReadInt32 (); object[] fields = new object[FieldCount]; ColumnSet cs = css [columnSet]; if (cs.Columns.Length != fields.Length) throw new Exception (); for (int n = 0; n != fields.Length; n++) { bool Null = BR.ReadBoolean (); if (Null) { fields [n] = null; continue; } switch (cs.Columns [n].TFQN) { case "System.Byte[]": fields [n] = BR.ReadBytes (BR.ReadInt32 ()); break; case "System.Byte": fields [n] = BR.ReadByte (); break; case "System.SByte": fields [n] = BR.ReadSByte (); break; case "System.Int16": fields [n] = BR.ReadInt16 (); break; case "System.UInt16": fields [n] = BR.ReadUInt16 (); break; case "System.Int32": fields [n] = BR.ReadInt32 (); break; case "System.UInt32": fields [n] = BR.ReadUInt32 (); break; case "System.Int64": fields [n] = BR.ReadInt64 (); break; case "System.UInt64": fields [n] = BR.ReadUInt64 (); break; case "System.Single": fields [n] = BR.ReadSingle (); break; case "System.Double": fields [n] = BR.ReadDouble (); break; case "System.String": fields [n] = BR.ReadString (); break; case "System.Char": fields [n] = BR.ReadChar (); break; case "System.Boolean": fields [n] = BR.ReadBoolean (); break; case "System.DateTime": fields [n] = new DateTime (BR.ReadInt64 ()); break; case "System.Guid": fields [n] = new Guid (BR.ReadBytes (16)); break; } } return new Row (cs, fields); } } }