本文整理汇总了C#中System.IO.BinaryReader.ReadInt64方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadInt64方法的具体用法?C# BinaryReader.ReadInt64怎么用?C# BinaryReader.ReadInt64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadInt64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public IDictionary<byte[], IList<long>> Read(BinaryReader reader, int keyWidth)
{
var indexWidth = reader.ReadInt64();
var buckets = new Dictionary<byte[], IList<long>>(new ByteArrayComparer());
while (reader.BaseStream.Position < reader.BaseStream.Length)
{
var bucket = new List<long>();
var index = reader.ReadBytes(keyWidth);
for (int i = 0; i < indexWidth - keyWidth; i += sizeof (long))
{
var value = reader.ReadInt64();
if (value != long.MaxValue)
{
bucket.Add(value);
}
else
{
reader.BaseStream.Seek(indexWidth - keyWidth - i - sizeof (long), SeekOrigin.Current);
break;
}
}
buckets[index] = bucket;
}
return buckets;
}
示例2: Chests
public Chests(BinaryReader inStream)
{
Id = inStream.ReadInt32();
Flag0 = inStream.ReadBoolean();
Unknown0 = inStream.ReadInt32();
Name = inStream.ReadInt32();
AnimatedObject = inStream.ReadInt32();
Flag1 = inStream.ReadBoolean();
Flag2 = inStream.ReadBoolean();
Unknown1 = inStream.ReadInt32();
Flag3 = inStream.ReadBoolean();
Flag4 = inStream.ReadBoolean();
Unknown2 = inStream.ReadInt32();
Data0Length = inStream.ReadInt32();
Data0 = inStream.ReadInt32();
Data1Length = inStream.ReadInt32();
Data1 = inStream.ReadInt32();
ItemKey = inStream.ReadInt64();
Flag5 = inStream.ReadBoolean();
Data2Length = inStream.ReadInt32();
Data2 = inStream.ReadInt32();
Flag6 = inStream.ReadBoolean();
Data3Length = inStream.ReadInt32();
Data3 = inStream.ReadInt32();
Unknown3 = inStream.ReadInt64();
Unknown4 = inStream.ReadInt32();
Flag7 = inStream.ReadBoolean();
Data4Length = inStream.ReadInt32();
Data4 = inStream.ReadInt32();
Unknown23 = inStream.ReadInt32();
}
示例3: DeserializeBody
public override void DeserializeBody(BinaryReader br)
{
dc_id = br.ReadInt32();
volume_id = br.ReadInt64();
local_id = br.ReadInt32();
secret = br.ReadInt64();
}
示例4: Open
public void Open()
{
if(!File.Exists(attributionFileName))
{
throw new FileNotFoundException("The specified attribution file is not found");
}
attributionFileStreamReader = new BinaryReader(File.Open(attributionFileName, FileMode.Open));
attributionFileStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
recordsCount = attributionFileStreamReader.ReadInt32();
dataOffset = attributionFileStreamReader.ReadInt64();
for (int i = 0; i < recordsCount; i++)
{
if (indexOffsets == null)
{
indexOffsets = new Dictionary<int, long>();
}
indexOffsets.Add(i, attributionFileStreamReader.ReadInt64());
}
isOpened = true;
}
示例5: DeserializeBody
public override void DeserializeBody(BinaryReader br)
{
id = br.ReadInt64();
access_hash = br.ReadInt64();
date = br.ReadInt32();
sizes = (TLVector<TLAbsPhotoSize>)ObjectUtils.DeserializeVector<TLAbsPhotoSize>(br);
}
示例6: ListFiles
public IEnumerable<FileEntry> ListFiles(Stream strm, Callbacks callbacks)
{
byte[] buf = new byte[4];
BinaryReader rd = new BinaryReader(strm);
int numFiles;
List<FileEntry> results = new List<FileEntry>();
rd.Read(buf, 0, 4);
if (Encoding.ASCII.GetString(buf, 0, 4) != "TGP0")
return results;
if (rd.ReadInt32() != 1) // version check
return results;
if (rd.ReadInt32() != 0) // should be zero
return results;
numFiles = rd.ReadInt32();
buf = new byte[0x60];
for (int i = 0; i < numFiles; i++)
{
FileEntry ent = new FileEntry();
rd.Read(buf, 0, 0x60);
ent.Filename = Encoding.ASCII.GetString(buf);
ent.Filename = ent.Filename.Substring(0, ent.Filename.IndexOf('\0'));
ent.Offset = rd.ReadInt64();
ent.UncompressedSize = rd.ReadInt64();
results.Add(ent);
}
return results;
}
示例7: TestWrite
public void TestWrite()
{
MemoryStream stream = new MemoryStream();
// FileIndex should support a stream starting at any point
stream.Seek(10, SeekOrigin.Begin);
PostingListEncoder decoder = new PostingListEncoder();
PerformWrite(stream);
BinaryReader reader = new BinaryReader(stream);
// Term count
Assert.AreEqual(2, reader.ReadInt64());
long ptr1 = reader.ReadInt64();
long ptr2 = reader.ReadInt64();
Assert.AreEqual(stream.Position, ptr1);
Assert.AreEqual("aTerm", reader.ReadString());
IList<Posting> postings = decoder.read(reader);
Assert.AreEqual(2, postings.Count);
Assert.AreEqual(new Posting(DocA, 1), postings[0]);
Assert.AreEqual(new Posting(DocB, 1), postings[1]);
Assert.AreEqual(stream.Position, ptr2);
Assert.AreEqual("bTerm", reader.ReadString());
postings = decoder.read(reader);
Assert.AreEqual(3, postings.Count);
Assert.AreEqual(new Posting(DocA, 1), postings[0]);
Assert.AreEqual(new Posting(DocZ, 1), postings[1]);
Assert.AreEqual(new Posting(DocT, 1), postings[2]);
}
示例8: ProgramHeader
public ProgramHeader(BinaryReader reader, bool Is64Bit)
{
this.Type = (HeaderType)reader.ReadUInt32();
// 64-bit reads flags here
if (Is64Bit) { this.SegmentFlags = (SegmentFlags)reader.ReadUInt32(); }
this.SegmentOffset = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();
this.VirtualAddress = Is64Bit ? reader.ReadUInt64() : reader.ReadUInt32();
// Skip physical address - reserved
if (Is64Bit) reader.ReadUInt64(); else reader.ReadUInt32();
this.SegmentFileSize = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();
this.SegmentLoadedSize = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();
// 32-bit reads flags here
if (!Is64Bit) { this.SegmentFlags = (SegmentFlags)reader.ReadUInt32(); }
this.Alignment = Is64Bit ? reader.ReadInt64() : reader.ReadUInt32();
if (this.SegmentOffset < 0 || this.SegmentFileSize < 0 ||
this.SegmentLoadedSize < 0 || this.Alignment < 0)
{
throw new BadImageFormatException("Program header values are too large to be " +
"supported by this implementation");
}
}
示例9: IndexedFS
public IndexedFS(Filesystem msys)
{
_msys = msys;
if (!msys.EnumFiles().GetEnumerator().MoveNext())
{
//Create index
msys.AllocSpace(0,512);
Stream mstream = new ObservableStream(0, msys);
BinaryWriter mwriter = new BinaryWriter(mstream);
mwriter.Write(filemappings.Count);
cval++;
}
ObservableStream fstr = new ObservableStream(0, msys);
BinaryReader mreader = new BinaryReader(fstr);
int count = mreader.ReadInt32();
for (int i = 0; i < count; i++)
{
if (mreader.ReadBoolean())
{
filemappings.Add(mreader.ReadString(), mreader.ReadInt64());
}
else
{
dirmappings.Add(mreader.ReadString(), mreader.ReadInt64());
}
cval++;
}
}
示例10: readHeader
public void readHeader(BinaryReader reader)
{
this.operation = reader.ReadByte();
int blockId = reader.ReadInt32();
int threadId = IPAddress.NetworkToHostOrder(reader.ReadInt32());
byte booleans = reader.ReadByte();
if (isTrue(booleans, 1))
{
timeout = IPAddress.NetworkToHostOrder(reader.ReadInt64());
}
if (isTrue(booleans, 2))
{
ttl = IPAddress.NetworkToHostOrder(reader.ReadInt64());
}
if (isTrue(booleans, 4))
{
longValue = IPAddress.NetworkToHostOrder(reader.ReadInt64());
}
this.callId = IPAddress.NetworkToHostOrder(reader.ReadInt64());
this.responseType = reader.ReadByte();
int nameLength = IPAddress.NetworkToHostOrder(reader.ReadInt32());
if (nameLength > 0)
{
byte[] b = new byte[nameLength];
reader.Read(b, 0, nameLength);
this.name = System.Text.Encoding.ASCII.GetString(b);
}
byte indexCount = reader.ReadByte();
int keyPartitionHash = IPAddress.NetworkToHostOrder(reader.ReadInt32());
int valuePartitionHash = IPAddress.NetworkToHostOrder(reader.ReadInt32());
}
示例11: ContentArchiveNode
/// <summary>
/// Initializes a new instance of the <see cref="ContentArchiveNode"/> class from an archive stream.
/// </summary>
/// <param name="parent">The node's parent node.</param>
/// <param name="reader">A <see cref="BinaryReader"/> on the stream containing the archive data.</param>
private ContentArchiveNode(ContentArchiveNode parent, BinaryReader reader)
{
this.parent = parent;
this.name = reader.ReadString();
this.path = BuildPath(parent, name);
this.isFile = reader.ReadBoolean();
this.isDirectory = !this.isFile;
if (this.isFile)
{
this.position = reader.ReadInt64();
this.sizeInBytes = reader.ReadInt64();
}
else
{
var childList = new List<ContentArchiveNode>();
var childCount = reader.ReadInt32();
for (int i = 0; i < childCount; i++)
{
var node = new ContentArchiveNode(this, reader);
childList.Add(node);
}
this.children = childList;
}
}
示例12: Cell
internal Partition part; // the partition containing this cell
#endregion Fields
#region Constructors
/// <summary>
/// Load a cell from disk into memory.
/// </summary>
/// <param name="part">The partition where this cell belongs</param>
/// <param name="fileName">The name of the file holding the persisted cell</param>
/// <exception cref="FileFormatException">The cell file is malformed</exception>
/// <exception cref="EndOfStreamException">The cell file is too short</exception>
internal Cell(Partition part, string fileName, bool partial)
{
this.part = part;
this.fileName = fileName;
var fileLength = new FileInfo(fileName).Length;
using (var br = new BinaryReader(new BufferedStream(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)))) {
this.baseUID = br.ReadInt64();
this.epoch = br.ReadInt32();
this.numUrls = br.ReadInt64();
this.supraUID = this.baseUID + this.numUrls;
this.urlCell = new UrlCell(this, br);
this.linkCell = new LinkCell[2];
this.linkCell[0] = new LinkCell(this, br);
this.linkCell[1] = new LinkCell(this, br);
long numHdrBytes = br.BaseStream.Position;
this.urlCell.startPos = numHdrBytes;
this.linkCell[0].startPos = this.urlCell.startPos + this.urlCell.numBytes;
this.linkCell[1].startPos = this.linkCell[0].startPos + this.linkCell[0].numBytes;
var expectedSize = numHdrBytes + this.urlCell.numBytes +
(partial ? 0L : this.linkCell[0].numBytes + this.linkCell[1].numBytes);
if (fileLength != expectedSize) {
throw new FileFormatException(fileName + " is wrong size");
}
}
}
示例13: ParseMessage
protected override void ParseMessage(byte[] messageBody)
{
// Read double from the stream
BinaryReader br = new BinaryReader(new MemoryStream(messageBody), Encoding.UTF8);
X = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(br.ReadInt64()));
Y = BitConverter.Int64BitsToDouble(IPAddress.NetworkToHostOrder(br.ReadInt64()));
}
示例14: TestWrite
public void TestWrite()
{
Stream stream = new MemoryStream();
PerformWrite(stream);
BinaryReader reader = new BinaryReader(stream);
stream.Seek(0, SeekOrigin.Begin);
Assert.AreEqual(2, reader.ReadInt64());
// term ptr, frequency
reader.ReadInt64();
Assert.AreEqual(2, reader.ReadInt32());
// term ptr, frequency
reader.ReadInt64();
Assert.AreEqual(3, reader.ReadInt32());
string[] strings = new string[] {
"aTerm", "aDoc", "bDoc", "bTerm", "aDoc", "zDoc", "tDoc"
};
foreach (string str in strings)
{
Assert.AreEqual(str, reader.ReadString());
}
}
示例15: Read
public override object Read(BinaryReader reader, byte version)
{
if (version == 0)
return new Bid(new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
else
return new Bid(new DateTime(reader.ReadInt64()), new DateTime(reader.ReadInt64()), reader.ReadByte(), reader.ReadInt32(), reader.ReadDouble(), reader.ReadInt32());
}