本文整理汇总了C#中System.IO.Stream.ReadStruct方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadStruct方法的具体用法?C# Stream.ReadStruct怎么用?C# Stream.ReadStruct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.Stream
的用法示例。
在下文中一共展示了Stream.ReadStruct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadBallFromStream
private static Ball ReadBallFromStream(Stream str)
{
var ret = new Ball {Header = str.ReadStruct<BallHeader>()};
if (ret.Header.Mode != BallMode.Rigid)
ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();
if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
ret.Data = str.ReadStruct<BallData>();
var reader = new BinaryReader(str);
ret.FormationId = reader.ReadByte();
switch (ret.Header.Mode)
{
case BallMode.Follow:
case BallMode.Orbit:
ret.FollowState = str.ReadStruct<FollowState>();
break;
case BallMode.Formation:
ret.FormationState = str.ReadStruct<FormationState>();
break;
case BallMode.Troll:
ret.TrollState = str.ReadStruct<TrollState>();
break;
case BallMode.Missile:
ret.MissileState = str.ReadStruct<MissileState>();
break;
case BallMode.Goto:
ret.GotoState = str.ReadStruct<GotoState>();
break;
case BallMode.Warp:
ret.WarpState = str.ReadStruct<WarpState>();
break;
case BallMode.Mushroom:
ret.MushroomState = str.ReadStruct<MushroomState>();
break;
case BallMode.Stop:
case BallMode.Field:
case BallMode.Rigid:
// no extra data for these
break;
}
if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
ret.MiniBalls = ReadMiniBalls(reader);
ret.Name = ReadString(reader);
return ret;
}
示例2: ReadChunk
public Chunk ReadChunk(Stream Stream)
{
var ChunkSize = (uint)Stream.ReadStruct<uint_be>();
//var ChunkType = (ushort)Stream.ReadStruct<ushort_be>();
var ChunkStream = Stream.ReadStream(ChunkSize);
return new Chunk()
{
Size = ChunkSize,
//Type = ChunkType,
Stream = ChunkStream,
};
}
示例3: Load
public Pmf Load(Stream Stream)
{
this.Stream = Stream;
Header = Stream.ReadStruct<HeaderStruct>();
var Chunk = ReadChunk(Stream.SliceWithLength(0x50));
InfoHeader = Chunk.Stream.ReadStruct<InfoHeaderStruct>();
/*
Console.WriteLine("0x{0:X}", (ulong)InfoHeader.FirstTimestamp);
Console.WriteLine("0x{0:X}", (ulong)InfoHeader.LastTimestamp);
Console.WriteLine("{0}", (ulong)InfoHeader.Width);
Console.WriteLine("{0}", (ulong)InfoHeader.Height);
*/
return this;
}
示例4: ReadHeader
private void ReadHeader(Stream str)
{
Header = str.ReadStruct<Header>();
if (Header.PacketType != 0 && Header.PacketType != 1)
throw new InvalidDataException("Unknown packet type; expected 0 or 1, got " + Header.PacketType);
}
示例5: ReadBallFromStream
private static Ball ReadBallFromStream(Stream str)
{
var ret = new Ball {Header = str.ReadStruct<BallHeader>()};
if (ret.Header.Mode != BallMode.Rigid)
ret.ExtraHeader = str.ReadStruct<ExtraBallHeader>();
if (ret.Header.Flags.HasFlag(BallFlag.IsFree))
ret.Data = str.ReadStruct<BallData>();
var reader = new BinaryReader(str);
ret.FormationId = reader.ReadByte();
switch (ret.Header.Mode)
{
case BallMode.Follow:
case BallMode.Orbit:
ret.FollowState = str.ReadStruct<FollowState>();
break;
case BallMode.Formation:
ret.FormationState = str.ReadStruct<FormationState>();
break;
case BallMode.Troll:
ret.TrollState = str.ReadStruct<TrollState>();
break;
case BallMode.Missile:
ret.MissileState = str.ReadStruct<MissileState>();
break;
case BallMode.Goto:
ret.GotoState = str.ReadStruct<GotoState>();
break;
case BallMode.Warp:
ret.WarpState = str.ReadStruct<WarpState>();
break;
case BallMode.Mushroom:
ret.MushroomState = str.ReadStruct<MushroomState>();
break;
case BallMode.Stop:
case BallMode.Field:
case BallMode.Rigid:
// no extra data for these
break;
}
if (ret.Header.Flags.HasFlag(BallFlag.HasMiniBalls))
ret.MiniBalls = ReadMiniBalls(reader);
// Crucible:
// no more names in destiny data
// most of them were invalid anyway, and slimitems have the name, so sensible change for CCP
//ret.Name = ReadString(reader);
return ret;
}