本文整理汇总了C#中System.IO.BinaryReader.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadInt32方法的具体用法?C# BinaryReader.ReadInt32怎么用?C# BinaryReader.ReadInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: fromFile
public Boolean fromFile(String path)
{
FileStream fs = new FileStream(path, FileMode.Open);
BinaryReader reader = new BinaryReader(fs);
try
{
String h = reader.ReadString();
float v = BitConverter.ToSingle(reader.ReadBytes(sizeof(float)), 0);
drawFloorModel = reader.ReadBoolean();
showAlwaysFloorMap = reader.ReadBoolean();
lockMapSize = reader.ReadBoolean();
mapXsize = reader.ReadInt32();
mapYsize = reader.ReadInt32();
//edgeXのxはmapX-1
//yはmapYsize
return true;
}
catch (EndOfStreamException eex)
{
//握りつぶす
return false;
}
finally
{
reader.Close();
}
}
示例2: RespawnInfo
public RespawnInfo(BinaryReader reader, int Version, int Customversion)
{
MonsterIndex = reader.ReadInt32();
Location = new Point(reader.ReadInt32(), reader.ReadInt32());
Count = reader.ReadUInt16();
Spread = reader.ReadUInt16();
Delay = reader.ReadUInt16();
Direction = reader.ReadByte();
if (Envir.LoadVersion >= 36)
{
RoutePath = reader.ReadString();
}
if (Version > 67)
{
RandomDelay = reader.ReadUInt16();
RespawnIndex = reader.ReadInt32();
SaveRespawnTime = reader.ReadBoolean();
RespawnTicks = reader.ReadUInt16();
}
else
{
RespawnIndex = ++SMain.Envir.RespawnIndex;
}
}
示例3: TightUnmarshal
//
// Un-marshal an object instance from the data input stream
//
public override void TightUnmarshal(OpenWireFormat wireFormat, Object o, BinaryReader dataIn, BooleanStream bs)
{
base.TightUnmarshal(wireFormat, o, dataIn, bs);
ConsumerInfo info = (ConsumerInfo)o;
info.ConsumerId = (ConsumerId) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
info.Browser = bs.ReadBoolean();
info.Destination = (ActiveMQDestination) TightUnmarshalCachedObject(wireFormat, dataIn, bs);
info.PrefetchSize = dataIn.ReadInt32();
info.MaximumPendingMessageLimit = dataIn.ReadInt32();
info.DispatchAsync = bs.ReadBoolean();
info.Selector = TightUnmarshalString(dataIn, bs);
info.SubscriptionName = TightUnmarshalString(dataIn, bs);
info.NoLocal = bs.ReadBoolean();
info.Exclusive = bs.ReadBoolean();
info.Retroactive = bs.ReadBoolean();
info.Priority = dataIn.ReadByte();
if (bs.ReadBoolean()) {
short size = dataIn.ReadInt16();
BrokerId[] value = new BrokerId[size];
for( int i=0; i < size; i++ ) {
value[i] = (BrokerId) TightUnmarshalNestedObject(wireFormat,dataIn, bs);
}
info.BrokerPath = value;
}
else {
info.BrokerPath = null;
}
info.AdditionalPredicate = (BooleanExpression) TightUnmarshalNestedObject(wireFormat, dataIn, bs);
info.NetworkSubscription = bs.ReadBoolean();
info.OptimizedAcknowledge = bs.ReadBoolean();
info.NoRangeAcks = bs.ReadBoolean();
}
示例4: readDicFile
public void readDicFile(string fileName)
{
fs = File.OpenRead(fileName);
br = new BinaryReader(fs);
int classNum = br.ReadInt32();
Console.WriteLine("classNum="+classNum);
int dim = br.ReadInt32();
Console.WriteLine("dim=" + dim);
int count,data;
while (fs.CanRead)
{
count = br.ReadInt32();
Console.WriteLine("count=" + count);
for (int i = 0; i < count; i++)
{
for (int j = 0; j < dim; j++)
{
data = br.ReadInt16();
//Console.Write(",data[" + j + "]=" + data);
Console.Write(data+",");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
示例5: GetAnimation
private Frame[] GetAnimation()
{
if (_patch.length < 1)
return null;
MemoryStream ms = new MemoryStream(_patch.data);
BinaryReader bin = new BinaryReader(ms);
if (_patch.length < 1)
return null;
ushort[] palette = new ushort[0x100];
for( int i = 0; i < 0x100; ++i )
palette[i] = (ushort)( bin.ReadUInt16() ^ 0x8000 );
int start = (int)bin.BaseStream.Position;
int frameCount = bin.ReadInt32();
int[] lookups = new int[frameCount];
for( int i = 0; i < frameCount; ++i )
lookups[i] = start + bin.ReadInt32();
Frame[] frames = new Frame[frameCount];
for( int i = 0; i < frameCount; ++i )
{
bin.BaseStream.Seek(lookups[i], SeekOrigin.Begin);
frames[i] = new Frame(palette, bin, false);
}
return frames;
}
示例6: Read
/// <summary>
/// Reads the specified reader.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="pageSize">Holds the size of a single page in the file.</param>
/// <param name="rootStream">The root stream.</param>
/// <returns></returns>
public static bool Read(BinaryReader reader, int pageSize, out PdbRootStream rootStream)
{
rootStream.streams = reader.ReadInt32();
Debug.WriteLine(String.Format(@"PdbRootStream: PDB file contains {0} streams.", rootStream.streams));
rootStream.streamLength = new int[rootStream.streams];
rootStream.streamPages = new int[rootStream.streams][];
for (int i = 0; i < rootStream.streams; i++)
rootStream.streamLength[i] = reader.ReadInt32();
for (int i = 0; i < rootStream.streams; i++)
{
Debug.WriteLine(String.Format("\tPDB Stream #{0} (Length {1} bytes)", i, rootStream.streamLength[i]));
if (rootStream.streamLength[i] > 0)
{
rootStream.streamPages[i] = new int[(rootStream.streamLength[i] / pageSize) + 1];
for (int j = 0; j < rootStream.streamPages[i].Length; j++)
{
rootStream.streamPages[i][j] = reader.ReadInt32();
Debug.WriteLine(String.Format("\t\tPage {0} (at offset {1})", rootStream.streamPages[i][j], rootStream.streamPages[i][j] * pageSize));
}
}
}
return true;
}
示例7: Decode
public override void Decode()
{
MemoryStream stream = new MemoryStream(Data);
BinaryReader reader = new BinaryReader(stream);
this.NumShapes = reader.ReadInt32();
this.LastShapeID = reader.ReadInt32();
}
示例8: IPHeader
private ushort usTotalLength; //Шестнадцать битов для общей длины датаграммы (заголовок + сообщение)
#endregion Fields
#region Constructors
public IPHeader(byte[] byBuffer, int nReceived)
{
try
{
MemoryStream memoryStream = new MemoryStream(byBuffer, 0, nReceived);
BinaryReader binaryReader = new BinaryReader(memoryStream);
byVersionAndHeaderLength = binaryReader.ReadByte();
byDifferentiatedServices = binaryReader.ReadByte();
usTotalLength = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
usIdentification = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
usFlagsAndOffset = (ushort)IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
byTTL = binaryReader.ReadByte();
byProtocol = binaryReader.ReadByte();
sChecksum = IPAddress.NetworkToHostOrder(binaryReader.ReadInt16());
uiSourceIPAddress = (uint)(binaryReader.ReadInt32());
uiDestinationIPAddress = (uint)(binaryReader.ReadInt32());
byHeaderLength = byVersionAndHeaderLength;
byHeaderLength <<= 4;
byHeaderLength >>= 4;
byHeaderLength *= 4;
Array.Copy(byBuffer, byHeaderLength, byIPData, 0, usTotalLength - byHeaderLength);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
示例9: ImportTables
/*
Achtung! Hier fehlt noch jegliches Error-Handling
Es wird nicht einmal geprüft ob die Datei mit VADB anfängt!
*/
public VDB_Table[] ImportTables(string filename)
{
BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open));
string formatID = reader.ReadString();
int formatVersion = reader.ReadInt32();
int tableCount = reader.ReadInt32();
VDB_Table[] tables = new VDB_Table[tableCount];
for (int i = 0; i < tableCount; i++) {
string tableName = reader.ReadString();
int columnCount = reader.ReadInt32();
string[] columns = new string[columnCount];
for (int j = 0; j < columnCount; j++) {
columns[j] = reader.ReadString();
}
int rowCount = reader.ReadInt32();
tables[i] = new VDB_Table(tableName, rowCount, columns);
}
string valueArea = reader.ReadString();
string[] values = valueArea.Split(VDB_DatabaseExporter.valuesSeperator);
for (int i = 0; i < values.Length - 1; i++) {
string[] posval = values[i].Split(VDB_DatabaseExporter.positionValueSeperator);
string[] pos = posval[0].Split(VDB_DatabaseExporter.positionSeperator);
int table = Int32.Parse(pos[0]);
int row = Int32.Parse(pos[1]);
int column = Int32.Parse(pos[2]);
tables[table].GetRowAt(row).values[column] = VDB_Value.FromBase64(posval[1]);
}
reader.Close();
return tables;
}
示例10: ReadFile
public static bool ReadFile(string FileName)
{
LCMeshReader.OpenedFile = FileName;
LCMeshReader.pMesh = new tMeshContainer();
BinaryReader b = new BinaryReader( new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read));
LCMeshReader.pMesh.HeaderInfo = new tHeaderInfo();
LCMeshReader.pMesh.HeaderInfo.Format = b.ReadBytes(4);
LCMeshReader.pMesh.HeaderInfo.Version = b.ReadInt32();
LCMeshReader.pMesh.HeaderInfo.MeshDataSize = b.ReadInt32();
LCMeshReader.pMesh.HeaderInfo.MeshCount = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.VertexCount = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.JointCount = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.TextureMaps = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.NormalCount = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.ObjCount = b.ReadUInt32();
LCMeshReader.pMesh.HeaderInfo.UnknownCount = b.ReadUInt32();
LCMeshReader.pMesh.FileName = b.ReadBytes(b.ReadInt32());
LCMeshReader.pMesh.Scale = b.ReadSingle();
LCMeshReader.pMesh.Value1 = b.ReadUInt32();
LCMeshReader.pMesh.FilePath = FileName;
bool flag = false;
if (LCMeshReader.pMesh.HeaderInfo.Version == 16)
{
if (LCMeshReader.ReadV10(b, b.BaseStream.Position))
flag = true;
}
else if (LCMeshReader.pMesh.HeaderInfo.Version == 17 && LCMeshReader.ReadV11(b, b.BaseStream.Position))
flag = true;
b.Close();
return flag;
}
示例11: SetDataFrom
public void SetDataFrom (BinaryReader reader)
{
File = reader.ReadString();
LineNumber = reader.ReadInt32();
LinePosition = reader.ReadInt32();
ErrorMessage = reader.ReadString();
}
示例12: EmmeMatrix
public EmmeMatrix(BinaryReader reader)
: this()
{
this.MagicNumber = reader.ReadUInt32();
if(!this.IsValidHeader())
{
return;
}
this.Version = reader.ReadInt32();
this.Type = (DataType)reader.ReadInt32();
this.Dimensions = reader.ReadInt32();
this.Indexes = new int[this.Dimensions][];
for(int i = 0; i < this.Indexes.Length; i++)
{
Indexes[i] = new int[reader.ReadInt32()];
}
for(int i = 0; i < this.Indexes.Length; i++)
{
var row = Indexes[i];
for(int j = 0; j < row.Length; j++)
{
row[j] = reader.ReadInt32();
}
}
LoadData(reader.BaseStream);
}
示例13: Load
public static void Load()
{
var local = GetData("UFSJ.S.uscx");
try
{
using (var i = new BinaryReader(File.OpenRead(local)))
{
if (i.ReadChar() == 'U')
{
OnTopMost = i.ReadBoolean(); //OnTopMost
SilentProgress = i.ReadBoolean(); //SilentProgress
ShowSummary = i.ReadBoolean(); //ShowSummary
AssociateExt = i.ReadBoolean(); //AssociateExt
StartHide = i.ReadBoolean(); //StartHide
ShellMenus = i.ReadBoolean(); //ShellMenus
SettingMode = i.ReadInt16(); //SettingMode
Theme = i.ReadString(); //ColorScheme
Language = i.ReadString(); //Language
Formats = i.ReadString(); //Formats
Position = new Point(i.ReadInt32(), i.ReadInt32());
}
}
}
catch (Exception)
{
SaveDefault();
Load();
}
}
示例14: ReadMesh
private static ModelMesh ReadMesh(BinaryReader r)
{
var data = new ModelMesh();
data.NumVerts = r.ReadInt32();
data.NumPrims = r.ReadInt32();
data.NumRefBones= r.ReadInt32();
data.RefBones = ReadList(r, data.NumRefBones, ReadRefBone);
foreach(var i in data.RefBones)
i.Matrix = ReadSingleArray(r, 16);
data.Vertices = ReadList(r, data.NumVerts, ReadVertex);
data.NumTangents= r.ReadInt32();
System.Diagnostics.Debug.Assert(data.NumTangents == 0);
data.Tangents = ReadList(r, data.NumTangents, ReadVector4);
data.Skins = ReadList(r, data.NumVerts, ReadSkin);
//System.Diagnostics.Debug.Assert(data.Unknown2 == 0);
data.Primitives = new List<ModelPrimitive>();
for(int i= 0; i < data.NumPrims; ++i)
{
var prim = new ModelPrimitive();
prim.NumIndices = r.ReadInt32();
prim.Indices = ReadList(r, prim.NumIndices, r.ReadUInt16);
data.Primitives.Add(prim);
}
return data;
}
示例15: FromFile
public static ModelFile FromFile(string file)
{
var data= new ModelFile() { FileName= file };
using(var s= File.OpenRead(file))
using(var r = new BinaryReader(s))
{
data.Magic = ReadString(r);
data.Version = r.ReadInt32();
data.Descriptions= ReadList(r, 2, ReadString);
data.NumBones = r.ReadInt32();
data.Bones = ReadList(r, data.NumBones, ReadBone);
foreach(var i in data.Bones)
i.ParentID = r.ReadInt32();
foreach(var i in data.Bones)
i.Params = ReadSingleArray(r, 7);
data.Mesh = ReadMesh(r);
data.NumMaterials= r.ReadInt32();
//System.Diagnostics.Debug.Assert(data.NumMaterials == 1);
data.Materials = ReadList(r, data.NumMaterials, ReadMaterial);
data.Params = ReadParamList(r);
}
return data;
}