本文整理汇总了C#中System.IO.BinaryReader.ReadSByte方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadSByte方法的具体用法?C# BinaryReader.ReadSByte怎么用?C# BinaryReader.ReadSByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadSByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
//byte[] buffer = new Buffer[512];
using (FileStream fs = File.Open(@"Z:\20121204.SVD", FileMode.Open, FileAccess.Read))
{
using (BinaryReader br = new BinaryReader(fs))
{
FileHead fh = new FileHead();
fh.Name = br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString();
fh.Ver = br.ReadSByte().ToString();
fh.Size = br.ReadInt16().ToString();
byte[] temp = new byte[8];
br.Read(temp, 0, 8);
//fh.MachineSN = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
fh.MachineSN = temp.ToHexString();
fh.BootVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
fh.SoftVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString();
fh.SumRecord = br.ReadInt32().ToString();
fh.UploadRecord = br.ReadInt32().ToString();
fh.NextUploadFPtr = br.ReadInt32().ToString();
Response.Write(fh.ToString());
}
}
}
示例2: readSector
public static FacetSector readSector(BinaryReader r) {
FacetSector fs = new FacetSector();
fs.facetID = r.ReadByte();
fs.sectorID = r.ReadUInt16();
for (int x = 0; x < 64; ++x) {
fs.tiles[x] = new facetTile_t[64];
for (int y = 0; y < 64; ++y) {
fs.tiles[x][y].z = r.ReadSByte();
fs.tiles[x][y].landtileGraphic = r.ReadUInt16();
fs.tiles[x][y].delimitersCount = r.ReadByte();
if (fs.tiles[x][y].delimitersCount > 0) {
fs.tiles[x][y].delimiters = new facetDelimiter_t[fs.tiles[x][y].delimitersCount];
for (int i = 0; i < fs.tiles[x][y].delimitersCount; ++i) {
fs.tiles[x][y].delimiters[i].direction = r.ReadByte();
if (fs.tiles[x][y].delimiters[i].direction < 8) {
fs.tiles[x][y].delimiters[i].z = r.ReadSByte();
fs.tiles[x][y].delimiters[i].graphic = r.ReadUInt32();
}
}
}
fs.tiles[x][y].staticsCount = r.ReadByte();
if (fs.tiles[x][y].staticsCount > 0) {
fs.tiles[x][y].statics = new facetStatic_t[fs.tiles[x][y].staticsCount];
for (int i = 0; i < fs.tiles[x][y].staticsCount; ++i) {
fs.tiles[x][y].statics[i].graphic = r.ReadUInt32();
fs.tiles[x][y].statics[i].z = r.ReadSByte();
fs.tiles[x][y].statics[i].color = r.ReadUInt32();
}
}
}
}
return fs;
}
示例3: InstrumentChunk
//--Methods
public InstrumentChunk(string id, int size, BinaryReader reader)
: base(id, size)
{
instNote = reader.ReadByte();
instFineTune = reader.ReadSByte();
instGain = reader.ReadSByte();
instLowNote = reader.ReadByte();
instHighNote = reader.ReadByte();
instLowVelocity = reader.ReadByte();
instHighVelocity = reader.ReadByte();
reader.ReadByte(); //always read pad
}
示例4: Metric
public Metric(BinaryReader br)
{
advance = br.ReadSingle();
u = br.ReadInt16();
v = br.ReadInt16();
bearingX = br.ReadSByte();
bearingY = br.ReadSByte();
width = br.ReadByte();
height = br.ReadByte();
first = br.ReadByte();
second = br.ReadByte();
prevNum = br.ReadByte();
nextNum = br.ReadByte();
}
示例5: ClientData
private void ClientData(BinaryReader source)
{
var mask = source.ReadUInt16();
var view_ofs_z = (0!=(mask & 0x0001))?source.ReadSByte():22;
var ang_ofs_1 = (0 != (mask & 0x0002)) ? (float)source.ReadSByte() : 0.0;
var angles_0 = (0 != (mask & 0x0004)) ? source.ReadSByte() : 0;
var vel_0 = (0 != (mask & 0x0020)) ? (source.ReadSByte()) : 0;
var angles_1 = (0 != (mask & 0x0008)) ? (source.ReadSByte()) : 0;
var vel_1 = (0 != (mask & 0x0040)) ? source.ReadSByte() : 0;
var angles_2 = (0 != (mask & 0x0010)) ? source.ReadSByte() : 0;
var vel_2 = (0 != (mask & 0x0080)) ? source.ReadSByte() : 0;
var items = (0 != (mask & 0x0200)) ? source.ReadInt32() : 0x4001;
var uk_bit_b10 = (0 != (mask & 0x0400)) ? 1 : 0; // bit 10
var uk_bit_b11 = (0 != (mask & 0x0800)) ? 1 : 0; // bit 11
var weaponframe = (0 != (mask & 0x1000)) ? source.ReadByte() : 0;
var armorvalue = (0 != (mask & 0x2000)) ? source.ReadByte() : 0;
var weaponmodel = (0 != (mask & 0x4000)) ? source.ReadByte() : 0;
var health = source.ReadInt16();
var currentammo = source.ReadByte();
var ammo_shells = source.ReadByte();
var ammo_nails = source.ReadByte();
var ammo_rockets = source.ReadByte();
var ammo_cells = source.ReadByte();
var weapon = source.ReadByte();
}
示例6: DeserializeToString
public static string DeserializeToString(byte[] data)
{
MemoryStream stream = new MemoryStream(data);
BinaryReader reader = new BinaryReader(stream);
reader.ReadSByte(); //取出第一个null字符
StringBuilder builder = new StringBuilder();
int count = reader.ReadInt32();
for (int i = 0; i < count; ++i)
{
sbyte flag = reader.ReadSByte();
if (flag == LineFlag)
{
int line = reader.ReadInt32();
flag = reader.ReadSByte();
int sourceLine = builder.ToString().Split('\n').Length;
for (int j = sourceLine; j < line; ++j)
builder.Append('\n');
}
TokenType type = (TokenType)flag;
object value = null;
switch (type)
{
case TokenType.Boolean:
value = (reader.ReadSByte() == 1);
break;
case TokenType.String:
value = "\"" + Util.ReadString(reader).Replace("\n", "\\n") + "\"";
break;
case TokenType.SimpleString:
value = "@\"" + Util.ReadString(reader) + "\"";
break;
case TokenType.Identifier:
value = Util.ReadString(reader);
break;
case TokenType.Number:
if (reader.ReadSByte() == 1)
value = reader.ReadDouble();
else
value = reader.ReadInt64() + "L";
break;
default:
value = GetTokenString(type);
break;
}
builder.Append(value + " ");
}
return builder.ToString();
}
示例7: Read
public void Read(BinaryReader reader, MDStream stream)
{
offs = reader.ReadUInt32 ();
size = reader.ReadUInt32 ();
StringBuilder name_builder = new StringBuilder ();
while (true) {
sbyte c = reader.ReadSByte();
if (c == 0)
break;
name_builder.Append ((char) c);
}
name = name_builder.ToString ();
if (name.Length == 0)
throw new BadImageException("Invalid stream name.");
// Round up to dword boundary.
long pos = reader.BaseStream.Position;
if (stream != null)
pos -= stream.Root.filePos;
pos += 3;
pos &= ~3;
if (stream != null)
pos += stream.Root.filePos;
// Advance file pointer.
reader.BaseStream.Position = pos;
}
示例8: Read
public static HighEnumLiteral Read(CatalogReader catalog, BinaryReader reader, uint literalSize, bool isSigned)
{
string name = catalog.GetString(reader.ReadUInt32());
long value;
switch (literalSize)
{
case 8:
value = reader.ReadInt64();
break;
case 4:
if (isSigned)
value = reader.ReadInt32();
else
value = reader.ReadUInt32();
break;
case 2:
if (isSigned)
value = reader.ReadInt16();
else
value = reader.ReadUInt16();
break;
case 1:
if (isSigned)
value = reader.ReadSByte();
else
value = reader.ReadByte();
break;
default:
throw new ArgumentException();
}
return new HighEnumLiteral(name, value);
}
示例9: Read
public override object Read(BinaryReader buffer, Type resultType, TypeDescription typeDescriptor, byte code, BinaryJSONReader binaryJsonReader)
{
switch (code)
{
case BinaryValue.BYTE:
return Convert.ChangeType(buffer.ReadByte(), resultType);
case BinaryValue.SBYTE:
return Convert.ChangeType(buffer.ReadSByte(), resultType);
case BinaryValue.INT16:
return Convert.ChangeType(buffer.ReadInt16(), resultType);
case BinaryValue.UINT16:
return Convert.ChangeType(buffer.ReadUInt16(), resultType);
case BinaryValue.INT32:
return Convert.ChangeType(buffer.ReadInt32(), resultType);
case BinaryValue.UINT32:
return Convert.ChangeType(buffer.ReadUInt32(), resultType);
case BinaryValue.INT64:
return Convert.ChangeType(buffer.ReadInt64(), resultType);
case BinaryValue.UINT64:
return Convert.ChangeType(buffer.ReadUInt64(), resultType);
case BinaryValue.FLOAT:
return Convert.ChangeType(buffer.ReadSingle(), resultType);
case BinaryValue.BOOLEAN:
return Convert.ChangeType(buffer.ReadBoolean(), resultType);
case BinaryValue.DOUBLE:
return Convert.ChangeType(buffer.ReadDouble(), resultType);
case BinaryValue.DECIMAL:
return Convert.ChangeType(buffer.ReadDecimal(), resultType);
case BinaryValue.CHAR:
return Convert.ChangeType(buffer.ReadChar(), resultType);
}
return null;
}
示例10: Deserialize
public override void Deserialize(BinaryReader reader)
{
base.Deserialize(reader);
Interaction = reader.ReadUInt16();
x = reader.ReadInt16();
y = reader.ReadInt16();
level = reader.ReadSByte();
}
示例11: DecodePackedFile
public static void DecodePackedFile(BinaryReader reader)
{
reader.ReadSByte();
List<string> dictionary = PS.readDictionary(reader);
XmlNode xmlroot = xDoc.CreateNode(XmlNodeType.Element, FileName, "");
PS.readElement(reader, xmlroot, xDoc, dictionary);
xDoc.AppendChild(xmlroot);
}
示例12: Deserialize
public override void Deserialize(BinaryReader reader)
{
Interaction = reader.ReadUInt16();
CallerID = reader.ReadInt16();
x = reader.ReadInt16();
y = reader.ReadInt16();
level = reader.ReadSByte();
}
示例13: Deserialize
public override void Deserialize(BinaryReader reader)
{
GUID = reader.ReadUInt32();
x = reader.ReadInt16();
y = reader.ReadInt16();
level = reader.ReadSByte();
dir = (Direction)reader.ReadByte();
}
示例14: readBase64
public string readBase64(BinaryReader reader, int lengthInBytes)
{
sbyte[] bytes = new sbyte[lengthInBytes];
for (int i = 0; i < lengthInBytes; i++)
{
bytes[i] = reader.ReadSByte();
}
return byteArrayToBase64(bytes);
}
示例15: ReadUInt16FromSbytes
public static uint ReadUInt16FromSbytes(BinaryReader br)
{
sbyte[] b = new sbyte[2];
for (int i = 0; i < 2; i++)
{
b[i] = br.ReadSByte();
}
return (ushort)(((b[0] & 0xff) << 8) | (b[1] & 0xff));
}