本文整理汇总了C#中EndianBinaryReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# EndianBinaryReader.ReadInt32方法的具体用法?C# EndianBinaryReader.ReadInt32怎么用?C# EndianBinaryReader.ReadInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EndianBinaryReader
的用法示例。
在下文中一共展示了EndianBinaryReader.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: read
public void read(EndianBinaryReader r) {
Time = r.ReadSingle();
Measure = r.ReadInt16();
Beat = r.ReadInt16();
PhraseIteration = r.ReadInt32();
Mask = r.ReadInt32();
}
示例2: FromByteArray
public void FromByteArray(ref byte[] datagram)
{
using (MemoryStream buffer = new MemoryStream(datagram))
{
using (EndianBinaryReader br = new EndianBinaryReader(new LittleEndianBitConverter(), buffer))
{
action = br.ReadInt32();
transaction_id = br.ReadInt32();
error = Encoding.UTF8.GetString(br.ReadBytes(datagram.Length - 8));
}
}
}
示例3: FromByteArray
public void FromByteArray(ref byte[] datagram)
{
using (MemoryStream buffer = new MemoryStream(datagram))
{
using (EndianBinaryReader br = new EndianBinaryReader(new BigEndianBitConverter(), buffer))
{
action = br.ReadInt32();
transaction_id = br.ReadInt32();
connection_id = br.ReadInt64();
}
}
}
示例4: Fill
static public void Fill(byte[] bytes)
{
var binReader = new EndianBinaryReader(Endian.LittleEndian, new MemoryStream(bytes));
binReader.Endian = binReader.ReadBoolean() ? Endian.LittleEndian : Endian.BigEndian;
var jumpPos = binReader.ReadInt32();
//跳过表头信息
binReader.BaseStream.Position = jumpPos;
/*
var headerCount = binReader.ReadInt32();
var headers = new string[headerCount];
var types = new string[headerCount];
for (var i = 0; i < headerCount; i++)
{
headers[i] = binReader.ReadUTF();
types[i] = binReader.ReadUTF();
}
*/
var count = binReader.ReadInt32();
for (int i = 0; i < count; i++)
{
var vo = new TeacherVO();
vo.decode(binReader);
list_vo.Add(vo);
dic_vo.Add(vo.Id, vo);
}
}
示例5: Parse
protected override void Parse(EndianBinaryReader r)
{
X = r.ReadInt32();
Z = r.ReadInt32();
Complete = r.ReadBoolean();
ChunkBitMap = r.ReadUInt16();
int length = ReadVarInt(r);
InitBuffer();
if (length != BlockType.Length + BlockMeta.Length + BlockLight.Length + BlockSkyLight.Length + (Complete ? Biome.Length : 0))
throw new InvalidDataException();
var s = r.BaseStream;
ReadBuffer(s, BlockType);
ReadBuffer(s, BlockMeta);
ReadBuffer(s, BlockLight);
ReadBuffer(s, BlockSkyLight);
if (Complete)
ReadBuffer(s, Biome);
}
示例6: FromByteArray
public void FromByteArray(ref byte[] datagram)
{
using (MemoryStream buffer = new MemoryStream(datagram))
{
using (EndianBinaryReader br = new EndianBinaryReader(new BigEndianBitConverter(), buffer))
{
action = br.ReadInt32();
transaction_id = br.ReadInt32();
interval = br.ReadInt32();
leechers = br.ReadInt32();
seeders = br.ReadInt32();
peers = new UdpPeer[((datagram.Length - 20) / 6)];
for (int i = 0; i < peers.Length; i++)
peers[i] = new UdpPeer(new IPAddress(br.ReadBytes(4)), br.ReadUInt16());
}
}
}
示例7: FromByteArray
public void FromByteArray(ref byte[] datagram)
{
using (MemoryStream buffer = new MemoryStream(datagram))
{
using (EndianBinaryReader br = new EndianBinaryReader(new BigEndianBitConverter(), buffer))
{
action = br.ReadInt32();
transaction_id = br.ReadInt32();
files = new TorrentStatistic[((datagram.Length - 8) / 12)];
for (int i = 0; i < files.Length; i++)
{
files[i] = new TorrentStatistic(br.ReadInt32(), br.ReadInt32(), br.ReadInt32(), String.Empty);
}
}
}
}
示例8: PaletteFile
public PaletteFile(string filename)
{
EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, File.Open(filename, FileMode.Open));
while (true)
{
int blockLength = 0;
PaletteBlockType blockType = (PaletteBlockType)reader.ReadInt32();
blockLength = reader.ReadInt32();
switch (blockType)
{
case PaletteBlockType.Attributes:
//contains name of palette and some attributes
//we dont care about this
reader.Seek(blockLength, SeekOrigin.Current);
break;
case PaletteBlockType.PixelData:
int entryCount = reader.ReadInt32();
int bytesPerEntry = reader.ReadInt32();
_paletteData = reader.ReadBytes(entryCount * bytesPerEntry);
break;
case PaletteBlockType.Null:
break;
default:
reader.Seek(blockLength, SeekOrigin.Current);
break;
}
if (reader.BaseStream.Position == reader.BaseStream.Length)
break;
}
reader.Close();
}
示例9: Read
/// <summary>
/// Reads next message from the stream and returns a deserialized object.
/// </summary>
/// <param name="raw">indicates whether reply should be parsed or return as raw data</param>
/// <returns>QMessage instance encapsulating a deserialized message.</returns>
public QMessage Read(bool raw = false)
{
_header = ReadFully(8);
var endianess = (Endianess) _header[0];
var messageType = (MessageType) _header[1];
var compressed = _header[2] == 1;
_reader = new EndianBinaryReader(_header) {Endianess = endianess};
_reader.Seek(4, SeekOrigin.Begin);
var messageSize = _reader.ReadInt32();
var dataSize = Math.Max(messageSize - 8, 0);
_rawData = ReadFully(dataSize);
if (raw)
{
return new QMessage(_rawData, messageType, endianess, compressed, raw, messageSize, dataSize);
}
var data = _rawData;
if (compressed)
{
data = Uncompress(_rawData, endianess);
dataSize = data.Length;
}
_reader = new EndianBinaryReader(data, endianess);
try
{
return new QMessage(ReadObject(), messageType, endianess, compressed, raw, messageSize, dataSize);
}
catch (QReaderException e)
{
ProtocolDebug(e);
throw;
}
catch (QException)
{
throw;
}
catch (Exception e)
{
ProtocolDebug(e);
throw;
}
}
示例10: Read
/// <summary>
/// Reads next message from the stream and returns a deserialized object.
/// </summary>
/// <param name="raw">indicates whether reply should be parsed or return as raw data</param>
/// <returns>QMessage instance encapsulating a deserialized message.</returns>
public QMessage Read(bool raw = false)
{
header = ReadFully(8);
Endianess endianess = (Endianess)header[0];
MessageType messageType = (MessageType)header[1];
bool compressed = header[2] == 1;
reader = new EndianBinaryReader(header) { Endianess = endianess };
reader.Seek(4, SeekOrigin.Begin);
int messageSize = reader.ReadInt32();
int dataSize = Math.Max(messageSize - 8, 0);
rawData = ReadFully(dataSize);
if (raw)
{
return new QMessage(rawData, messageType, endianess, compressed, raw, messageSize, dataSize);
}
var data = rawData;
if (compressed)
{
data = Uncompress(rawData, endianess);
dataSize = data.Length;
}
reader = new EndianBinaryReader(data, endianess);
try
{
return new QMessage(ReadObject(), messageType, endianess, compressed, raw, messageSize, dataSize);
}
catch (QReaderException e)
{
ProtocolDebug(e);
throw e;
}
catch (QException e)
{
throw e;
}
catch (Exception e)
{
ProtocolDebug(e);
throw e;
}
}
示例11: SidReader
/// <summary>
/// Constructor
/// </summary>
/// <param name="path">File path to the SID file.</param>
public SidReader(string path)
{
using (var sid = new EndianBinaryReader(File.OpenRead(path), Endian.Big))
{
// Get some flag values beforehand
// Video standard/chip model/BASIC flag
sid.BaseStream.Seek(0x76, SeekOrigin.Begin);
short flag = sid.ReadInt16();
VideoStandard = GetVideoStandard(flag);
ChipModel = GetChipModel(flag);
IsBasicFlagSet = BasicFlagIsSet(flag);
sid.BaseStream.Seek(0x00, SeekOrigin.Begin);
// Header
HeaderID = new string(sid.ReadChars(4));
// Version number (Shift because big-endian)
Version = sid.ReadInt16();
// Offset to C64 binary data
DataOffset = sid.ReadInt16();
// Addresses
LoadAddress = GetLoadAddress(sid);
InitAddress = GetInitAddress(sid);
PlayAddress = GetPlayAddress(sid);
// Songs
Songs = sid.ReadInt16();
StartSong = sid.ReadInt16();
// Speed integer
Speed = sid.ReadInt32();
// Song, Artist and Copyright
SongTitle = new string(sid.ReadChars(32));
Artist = new string(sid.ReadChars(32));
Copyright = new string(sid.ReadChars(32));
}
}
示例12: sendCommand
/**
* Send the XML request string
*/
public String sendCommand(string command)
{
try {
bw = new EndianBinaryWriter(new BigEndianBitConverter(), tcS);
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byte[] bytes = encoding.GetBytes(command);
bw.Write(bytes.Length);
bw.Write(bytes);
bw.Flush();
br = new EndianBinaryReader(new BigEndianBitConverter(), tcS);
int i = br.ReadInt32();
byte[] bytess = new byte[i];
br.Read(bytess, 0, i);
String response = encoding.GetString(bytess, 0, i);
Console.WriteLine(response);
return response;
} catch (Exception) {
return "";
}
}
示例13: Load
public static Type Load(Stream stream)
{
var reader = new EndianBinaryReader(EndianBitConverter.Big, stream);
int magic = reader.ReadInt32();
short minorVersion = reader.ReadInt16();
short majorVersion = reader.ReadInt16();
List<CompileConstant> constants = new List<CompileConstant>(ReadConstants(reader));
var modifiers = (ClassModifier)reader.ReadInt16();
short thisClass = reader.ReadInt16();
short superClass = reader.ReadInt16();
IEnumerable<short> interfaces = ReadInterfaces(reader);
IEnumerable<CompileFieldInfo> fields = ReadFields(reader, constants);
IEnumerable<CompileMethodInfo> methods = ReadMethods(reader, constants);
CompileAttribute[] attributes = ReadAttributes(reader, constants);
var c = new Class
{
Name = GetClass(thisClass, constants).Name,
Modifiers = modifiers,
Super = (superClass == 0 ? null : GetClass(superClass, constants)) as Class
};
c.Interfaces.AddRange(interfaces.Select(x => GetClass(x, constants)).OfType<Interface>());
c.Fields.AddRange(fields.Select(x => GetField(c, x, constants)));
List<Method> javaMethods = methods.Select(x => GetMethod(c, x, constants)).ToList();
c.Methods.AddRange(javaMethods.Where(x => x.Name != "<init>"));
c.Constructors.AddRange(javaMethods.Where(x => x.Name == "<init>").Select(x => (Constructor)x));
return c;
}
示例14: decode
public void decode(EndianBinaryReader binReader)
{
_Id = int.Parse(binReader.ReadUTF());
_Name = binReader.ReadUTF();
_Age = int.Parse(binReader.ReadUTF());
_Sex = binReader.ReadUTF().ToLower() == "true";
_Jump = float.Parse(binReader.ReadUTF());
_Time = DateTime.Parse(binReader.ReadUTF());
var len_StringList = binReader.ReadInt32();
_StringList = new string[len_StringList];
for (int i = 0; i < len_StringList; i++)
{
_StringList[i] = binReader.ReadUTF();
}
}
示例15: MatFile
public MatFile(string filename)
{
Stream file = OpenDataFile(filename);
if (!Exists)
return;
EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file);
CMaterial currentMaterial = null;
while (true)
{
int blockLength = 0;
MaterialBlockType blockType = (MaterialBlockType)reader.ReadInt32();
blockLength = reader.ReadInt32();
byte[] flags;
switch (blockType)
{
case MaterialBlockType.Attributes:
currentMaterial = new CMaterial();
_materials.Add(currentMaterial);
byte[] color = reader.ReadBytes(4);
byte[] otherColors = reader.ReadBytes(16);
flags = reader.ReadBytes(2);
byte[] transform = reader.ReadBytes(24);
currentMaterial.SimpMatPixelIndex = reader.ReadByte();
currentMaterial.SimpMatGradientCount = reader.ReadByte();
currentMaterial.DoubleSided = flags[0] == 0x10;
currentMaterial.Name = ReadNullTerminatedString(reader);
break;
case MaterialBlockType.AttributesV2:
currentMaterial = new CMaterial();
_materials.Add(currentMaterial);
reader.ReadBytes(4); //color
reader.ReadBytes(16); //othercolors
flags = reader.ReadBytes(4); // flags
reader.ReadBytes(24); //transform
reader.ReadBytes(4); //unk
currentMaterial.DoubleSided = flags[0] == 0x10;
reader.BaseStream.Position += 13;
currentMaterial.Name = ReadNullTerminatedString(reader);
break;
case MaterialBlockType.TextureName:
currentMaterial.PixName = ReadNullTerminatedString(reader);
break;
case MaterialBlockType.TabName:
string tabName = ReadNullTerminatedString(reader);
break;
case MaterialBlockType.Null:
break;
default:
reader.Seek(blockLength, SeekOrigin.Current);
break;
}
if (reader.BaseStream.Position == reader.BaseStream.Length)
break;
}
reader.Close();
}