本文整理汇总了C#中System.IO.BinaryReader.ReadInt64方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryReader.ReadInt64方法的具体用法?C# System.IO.BinaryReader.ReadInt64怎么用?C# System.IO.BinaryReader.ReadInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了System.IO.BinaryReader.ReadInt64方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnChooseFile_Click
private void btnChooseFile_Click(object sender, RoutedEventArgs e)
{
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
dlg.DefaultExt = ".data";
dlg.Filter = "Frame data (*.data)|*.data";
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
frameList.Clear();
// Open document
string filename = dlg.FileName;
using (System.IO.BinaryReader br =
new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open)))
{
while (br.BaseStream.Position < br.BaseStream.Length)
{
//deserialises and reads the binary file
DateTime date = new DateTime();
date = DateTime.FromBinary(br.ReadInt64());
// Console.WriteLine(date.ToString());
Int32 stimCode = br.ReadInt32();
Int32 nextBlock = br.ReadInt32();
byte[] frameData = br.ReadBytes(nextBlock);
Leap.Frame newFrame = new Leap.Frame();
newFrame.Deserialize(frameData);
if (stimCode == 5443)
{
Debug.WriteLine("5443 detected: " + newFrame.Id);
}
frameList.Add(newFrame);
//Console.WriteLine(newFrame.CurrentFramesPerSecond);
}
br.Close();
br.Dispose();
}
/* WRITE CODE HERE TO EXTRACT DATA FROM FILE
foreach (Leap.Frame frame in frameList)
{
//Console.WriteLine(frame.Id);
}
*/
}
}
示例2: Deserialize
public static TransparentStreamGetLengthResponseMessage Deserialize(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException ("buffer");
Guid streamID;
Guid requestID;
long length;
Exception exception;
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
streamID = new Guid (BR.ReadBytes (16));
requestID = new Guid (BR.ReadBytes (16));
length = BR.ReadInt64 ();
if (MS.ReadByte () == 1) {
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter BF = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter ();
object deserializedObject = BF.Deserialize (MS);
if (deserializedObject is Exception) {
exception = (Exception)deserializedObject;
} else {
throw new Exception ("buffer contains an object of invalid type, expected System.Exception.");
}
} else
exception = null;
}
}
return new TransparentStreamGetLengthResponseMessage (streamID, requestID, length, exception);
}
示例3: Deserialzie
public static ChunkHeaderv1 Deserialzie(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException ("buffer");
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
return new ChunkHeaderv1 (DateTime.FromBinary (BR.ReadInt64 ()), BR.ReadString ());
}
}
}
示例4: LoadLogs
/// <summary>Loads the black-box logs from the previous simulation run</summary>
internal static void LoadLogs()
{
string BlackBoxFile = OpenBveApi.Path.CombineFile(Program.FileSystem.SettingsFolder, "logs.bin");
try
{
using (System.IO.FileStream Stream = new System.IO.FileStream(BlackBoxFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
using (System.IO.BinaryReader Reader = new System.IO.BinaryReader(Stream, System.Text.Encoding.UTF8))
{
byte[] Identifier = new byte[] { 111, 112, 101, 110, 66, 86, 69, 95, 76, 79, 71, 83 };
const short Version = 1;
byte[] Data = Reader.ReadBytes(Identifier.Length);
for (int i = 0; i < Identifier.Length; i++)
{
if (Identifier[i] != Data[i]) throw new System.IO.InvalidDataException();
}
short Number = Reader.ReadInt16();
if (Version != Number) throw new System.IO.InvalidDataException();
Game.LogRouteName = Reader.ReadString();
Game.LogTrainName = Reader.ReadString();
Game.LogDateTime = DateTime.FromBinary(Reader.ReadInt64());
Interface.CurrentOptions.GameMode = (Interface.GameMode)Reader.ReadInt16();
Game.BlackBoxEntryCount = Reader.ReadInt32();
Game.BlackBoxEntries = new Game.BlackBoxEntry[Game.BlackBoxEntryCount];
for (int i = 0; i < Game.BlackBoxEntryCount; i++)
{
Game.BlackBoxEntries[i].Time = Reader.ReadDouble();
Game.BlackBoxEntries[i].Position = Reader.ReadDouble();
Game.BlackBoxEntries[i].Speed = Reader.ReadSingle();
Game.BlackBoxEntries[i].Acceleration = Reader.ReadSingle();
Game.BlackBoxEntries[i].ReverserDriver = Reader.ReadInt16();
Game.BlackBoxEntries[i].ReverserSafety = Reader.ReadInt16();
Game.BlackBoxEntries[i].PowerDriver = (Game.BlackBoxPower)Reader.ReadInt16();
Game.BlackBoxEntries[i].PowerSafety = (Game.BlackBoxPower)Reader.ReadInt16();
Game.BlackBoxEntries[i].BrakeDriver = (Game.BlackBoxBrake)Reader.ReadInt16();
Game.BlackBoxEntries[i].BrakeSafety = (Game.BlackBoxBrake)Reader.ReadInt16();
Game.BlackBoxEntries[i].EventToken = (Game.BlackBoxEventToken)Reader.ReadInt16();
}
Game.ScoreLogCount = Reader.ReadInt32();
Game.ScoreLogs = new Game.ScoreLog[Game.ScoreLogCount];
Game.CurrentScore.Value = 0;
for (int i = 0; i < Game.ScoreLogCount; i++)
{
Game.ScoreLogs[i].Time = Reader.ReadDouble();
Game.ScoreLogs[i].Position = Reader.ReadDouble();
Game.ScoreLogs[i].Value = Reader.ReadInt32();
Game.ScoreLogs[i].TextToken = (Game.ScoreTextToken)Reader.ReadInt16();
Game.CurrentScore.Value += Game.ScoreLogs[i].Value;
}
Game.CurrentScore.Maximum = Reader.ReadInt32();
Identifier = new byte[] { 95, 102, 105, 108, 101, 69, 78, 68 };
Data = Reader.ReadBytes(Identifier.Length);
for (int i = 0; i < Identifier.Length; i++)
{
if (Identifier[i] != Data[i]) throw new System.IO.InvalidDataException();
}
Reader.Close();
} Stream.Close();
}
}
catch
{
Game.LogRouteName = "";
Game.LogTrainName = "";
Game.LogDateTime = DateTime.Now;
Game.BlackBoxEntries = new Game.BlackBoxEntry[256];
Game.BlackBoxEntryCount = 0;
Game.ScoreLogs = new Game.ScoreLog[64];
Game.ScoreLogCount = 0;
}
}
示例5: readSeparateIndex
public static void readSeparateIndex(System.IO.Stream index, System.IO.Stream XMLBytes, int XMLSize, VTDGen vg)
{
if (index == null || vg == null || XMLBytes == null)
{
throw new System.ArgumentException("Invalid argument(s) for readIndex()");
}
//UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader'
//which has a different behavior.
//"ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
System.IO.BinaryReader dis = new System.IO.BinaryReader(index);
byte b = dis.ReadByte(); // first byte
// no check on version number for now
// second byte
vg.encoding = dis.ReadByte();
int intLongSwitch;
int endian;
// third byte
b = dis.ReadByte();
if ((b & 0x80) != 0)
intLongSwitch = 1;
//use ints
else
intLongSwitch = 0;
if ((b & 0x40) != 0)
vg.ns = true;
else
vg.ns = false;
if ((b & 0x20) != 0)
endian = 1;
else
endian = 0;
if ((b & 0x1f) != 0)
throw new IndexReadException("Last 5 bits of the third byte should be zero");
// fourth byte
vg.VTDDepth = dis.ReadByte();
// 5th and 6th byte
int LCLevel = (((int)dis.ReadByte()) << 8) | dis.ReadByte();
if (LCLevel != 4 && LCLevel != 6)
{
throw new IndexReadException("LC levels must be at least 3");
}
// 7th and 8th byte
vg.rootIndex = (((int)dis.ReadByte()) << 8) | dis.ReadByte();
// skip a long
dis.ReadInt64();
//Console.WriteLine(" l ==>" + l);
dis.ReadInt64();
//Console.WriteLine(" l ==>" + l);
long l = dis.ReadInt64();
int size;
// read XML size
if (BitConverter.IsLittleEndian && endian == 0
|| BitConverter.IsLittleEndian == false && endian == 1)
size = (int)l;
else
size = (int)reverseLong(l);
// read XML bytes
byte[] XMLDoc = new byte[size];
XMLBytes.Read(XMLDoc, 0, size);
//dis.Read(XMLDoc, 0, size);
/*if ((size & 0x7) != 0)
{
int t = (((size >> 3) + 1) << 3) - size;
while (t > 0)
{
dis.ReadByte();
t--;
}
}*/
vg.setDoc(XMLDoc);
// skip a long
dis.ReadInt64();
//Console.WriteLine(" l ==>" + l);
dis.ReadInt64();
//Console.WriteLine(" l ==>" + l);
if (BitConverter.IsLittleEndian && endian == 0
|| BitConverter.IsLittleEndian == false && endian == 1)
{
// read vtd records
int vtdSize = (int)dis.ReadInt64();
while (vtdSize > 0)
{
vg.VTDBuffer.append(dis.ReadInt64());
vtdSize--;
}
// read L1 LC records
int l1Size = (int)dis.ReadInt64();
while (l1Size > 0)
{
vg.l1Buffer.append(dis.ReadInt64());
l1Size--;
}
//.........这里部分代码省略.........
示例6: Deserialize
public static TransparentStreamSetPositionRequestMessage Deserialize(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException ("buffer");
Guid id;
Guid streamID;
long position;
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
id = new Guid (BR.ReadBytes (16));
streamID = new Guid (BR.ReadBytes (16));
position = BR.ReadInt64 ();
}
}
return new TransparentStreamSetPositionRequestMessage (id, streamID, position);
}
示例7: LoadParsing
public void LoadParsing( string _corpus_path )
{
corpus_path = _corpus_path;
sent2pos = new List<long>();
// Читаем файл filepath построчно, запоминая позиции узлов <sentence ...> в особом
// индексном файле
index_path = System.IO.Path.Combine( System.IO.Path.GetTempPath(), System.IO.Path.GetFileNameWithoutExtension( corpus_path ) + ".XMLINDEX" );
// проверить, если такой файл уже существует и создан после файла парсинга, то можно просто загрузить его содержимое.
if( System.IO.File.Exists( index_path ) && System.IO.File.GetLastWriteTime( corpus_path ) < System.IO.File.GetLastWriteTime( index_path ) )
{
using( System.IO.BinaryReader rdr = new System.IO.BinaryReader( System.IO.File.Open( index_path, System.IO.FileMode.Open ) ) )
{
long filesize = rdr.BaseStream.Length;
long nrec = filesize / sizeof( long );
long[] recs = new long[nrec];
for( long i = 0; i < nrec; ++i )
{
sent2pos.Add( rdr.ReadInt64() );
}
}
}
else
{
using( System.IO.BinaryWriter index_wrt = new System.IO.BinaryWriter( System.IO.File.Open( index_path, System.IO.FileMode.Create ) ) )
{
using( System.IO.FileStream rdr = new System.IO.FileStream( corpus_path, System.IO.FileMode.Open ) )
{
while( true )
{
long pos = rdr.Position;
string line = ReadLine( rdr );
if( string.IsNullOrEmpty( line ) )
{
continue;
}
if( line == "</parsing>" )
break;
if( line.StartsWith( "<sentence" ) )
{
index_wrt.Write( pos );
sent2pos.Add( pos );
}
}
}
}
}
return;
}
示例8: LoadData
/// <summary>
/// データ読み込み
/// </summary>
public static void LoadData()
{
// ここではファイルに保存したデータを読み込み、Parametersのプロパティに設定します
// コイン枚数初期値を設定
TotalCoinCount = INIT_COIN;
// 投入コイン初期値を設定
InsertCoinCount = 0;
// 最終コイン補充時間初期値を設定
LastRefillCoinTime = DateTime.Now;
// 最終更新時間初期値を設定
LastUpdateTime = DateTime.Now;
// ファイル存在チェック
if(System.IO.File.Exists(@SAVE_FILE))
{
// ファイルが存在する場合
using(var fs = System.IO.File.Open(@SAVE_FILE, System.IO.FileMode.Open))
{
// バイナリリーダー作成
var br = new System.IO.BinaryReader(fs);
// データ読み込み
LastUpdateTime = new DateTime(br.ReadInt64()); // 最終更新時間
LastRefillCoinTime = new DateTime(br.ReadInt64()); // 最終コイン補充時間
TotalCoinCount = br.ReadInt64(); // 残コイン数
InsertCoinCount = br.ReadInt32(); // 投入コイン数
// 各種クローズ処理
br.Close();
fs.Close();
}
}
}
示例9: Deserialize
public static Column Deserialize(byte[] bytes)
{
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
return new Column (new Guid (BR.ReadBytes (16)), BR.ReadString (), BR.ReadBoolean (), BR.ReadInt64 (), BR.ReadString ());
}
}
}
示例10: TryLoadCachedGroup
private bool TryLoadCachedGroup(byte[] data, DateTime lastWriteTime)
{
var timer = System.Diagnostics.Stopwatch.StartNew();
var reader = new BinaryReader(new MemoryStream(data), Encoding.UTF8);
DateTime cacheTime = new DateTime(reader.ReadInt64(), DateTimeKind.Utc);
if (cacheTime != lastWriteTime)
return false;
Dictionary<int, object> objects = new Dictionary<int, object>();
objects.Add(0, null);
// first pass constructs objects
long objectTableOffset = reader.BaseStream.Position;
int objectCount = reader.ReadInt32();
for (int i = 0; i < objectCount; i++)
{
int key = reader.ReadInt32();
object obj = CreateGroupObject(reader, key, objects);
objects.Add(key, obj);
}
reader.BaseStream.Seek(objectTableOffset + 4, SeekOrigin.Begin);
for (int i = 0; i < objectCount; i++)
{
int key = reader.ReadInt32();
LoadGroupObject(reader, key, objects);
}
List<TemplateGroup> importsToClearOnUnload = new List<TemplateGroup>();
Dictionary<string, CompiledTemplate> templates = new Dictionary<string, CompiledTemplate>();
Dictionary<string, IDictionary<string, object>> dictionaries = new Dictionary<string, IDictionary<string, object>>();
// imported groups
int importCount = reader.ReadInt32();
for (int i = 0; i < importCount; i++)
importsToClearOnUnload.Add((TemplateGroup)objects[reader.ReadInt32()]);
// delimiters
char delimiterStartChar = reader.ReadChar();
char delimiterStopChar = reader.ReadChar();
// templates & aliases
int templateCount = reader.ReadInt32();
for (int i = 0; i < templateCount; i++)
{
string key = reader.ReadString();
CompiledTemplate value = (CompiledTemplate)objects[reader.ReadInt32()];
templates[key] = value;
}
// dictionaries
int dictionaryCount = reader.ReadInt32();
for (int i = 0; i < dictionaryCount; i++)
{
string name = reader.ReadString();
IDictionary<string, object> dictionary = new Dictionary<string, object>();
dictionaries[name] = dictionary;
int valueCount = reader.ReadInt32();
for (int j = 0; j < valueCount; j++)
{
string key = reader.ReadString();
object value = objects[reader.ReadInt32()];
dictionary[key] = value;
}
}
this._importsToClearOnUnload.AddRange(importsToClearOnUnload);
this.delimiterStartChar = delimiterStartChar;
this.delimiterStopChar = delimiterStopChar;
foreach (var pair in templates)
this.templates[pair.Key] = pair.Value;
foreach (var pair in dictionaries)
this.dictionaries[pair.Key] = pair.Value;
System.Diagnostics.Debug.WriteLine(string.Format("Successfully loaded the cached group {0} in {1}ms.", Name, timer.ElapsedMilliseconds));
return true;
}
示例11: Deserialize
public static Column Deserialize(Frontend fb, byte[] chunkID, byte[] buffer)
{
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
return new Column (fb, chunkID, BR.ReadString (), fb.ValueSerializer.IDToType (BR.ReadByte ()), BR.ReadBoolean (), BR.ReadInt64 ());
}
}
}
示例12: Deserialize
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);
}
}
}
示例13: Deserialize
public static TransparentStreamSeekRequestMessage Deserialize(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException ("buffer");
Guid id;
Guid streamID;
long offset;
System.IO.SeekOrigin seekOrigin;
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (buffer)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
id = new Guid (BR.ReadBytes (16));
streamID = new Guid (BR.ReadBytes (16));
offset = BR.ReadInt64 ();
seekOrigin = (System.IO.SeekOrigin)BR.ReadInt32 ();
}
}
return new TransparentStreamSeekRequestMessage (id, streamID, offset, seekOrigin);
}