本文整理汇总了C#中System.IO.BinaryReader.ReadBoolean方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.BinaryReader.ReadBoolean方法的具体用法?C# System.IO.BinaryReader.ReadBoolean怎么用?C# System.IO.BinaryReader.ReadBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了System.IO.BinaryReader.ReadBoolean方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadData
/// <summary>
/// ファイルからデータをロード
/// </summary>
public static void LoadData()
{
if(System.IO.File.Exists(@SAVEFILE)){
using(var fs = System.IO.File.Open(@SAVEFILE,System.IO.FileMode.Open)){
// バイナリリーダ作成
var br = new System.IO.BinaryReader(fs);
// Read data
Global.isStageOpened[(int)StageID.Stage1] = br.ReadBoolean();
Global.isStageOpened[(int)StageID.Stage2] = br.ReadBoolean();
Global.isStageOpened[(int)StageID.Stage3] = br.ReadBoolean();
Global.characterLevel = br.ReadInt32();
Global.characterExp = br.ReadInt32();
br.Close();
}
}else{
Global.isStageOpened[(int)StageID.Stage1] = true;
Global.isStageOpened[(int)StageID.Stage2] = false;
Global.isStageOpened[(int)StageID.Stage3] = false;
Global.characterLevel = 1;
Global.characterExp = 0;
}
}
示例2: Deserialize
public static TransparentStreamCanReadResponseMessage Deserialize(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException ("buffer");
Guid streamID;
Guid requestID;
bool canRead;
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));
canRead = BR.ReadBoolean ();
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 TransparentStreamCanReadResponseMessage (streamID, requestID, canRead, exception);
}
示例3: Read_pachm
//.........这里部分代码省略.........
for (int s = 0; s < s_ct; s++)
{
Map[s] = new Mapping.PachMapReceiver();
Map[s].CutOffTime = (double)SampleCT / (double)SampleRate * 1000;
Map[s].SampleCT = SampleCT;
Map[s].SampleRate = SampleRate;
Map[s].Map_Mesh = Map_Mesh;
Map[s].Rec_List = new Mapping.PachMapReceiver.Map_Receiver[Rec_CT];
Map[s].Src = new Rhino.Geometry.Point3d(sr.ReadDouble(), sr.ReadDouble(), sr.ReadDouble());
Map[s].SrcType = sr.ReadString();
//4.4 Source delay (ms)
if (version > 2.0 || (version == 2.0 && rev >= 1))
{
delay[s] = sr.ReadDouble();
}
}
break;
case "Receiver Hit Data":
if (Map[0] == null)
{
Map = new Mapping.PachMapReceiver[1];
Map[0] = new Mapping.PachMapReceiver();
Map[0].CutOffTime = (double)SampleCT / (double)SampleRate;
Map[0].SampleRate = SampleRate;
Map[0].SampleCT = SampleCT;
Map[0].Map_Mesh = Map_Mesh;
Map[0].Rec_List = new Mapping.PachMapReceiver.Map_Receiver[Rec_CT];
Map[0].SrcType = "Geodesic";
}
//8. Announce that the following data pertains to the receiver histograms (string)
//8a. Announce whether or not data is linked to vertices rather than faces (bool)
bool vert_Receiver = sr.ReadBoolean();
for (int s = 0; s < s_ct; s++)
{
Map[s].Rec_Vertex = vert_Receiver;
for (int i = 0; i < Map[s].Rec_List.Length; i++)
{
//for version 1.7 and up, write direct sound arrival time.
//Write Receiver Index (int)
int j = (int)sr.ReadUInt32();
//Write Direct Sound Arrival Time.
double Direct_Time;
if (version >= 1.7) Direct_Time = sr.ReadDouble(); else Direct_Time = (Utilities.PachTools.RPttoHPt(Map[s].Src) - Map[s].Rec_List[i].H_Origin).Length() / 343f;
//Write Impedance of Air
double Rho_C = version >= 2.0 ? sr.ReadDouble() : 400;
if (vert_Receiver)
{
Map[s].Rec_List[i] = new Mapping.PachMapReceiver.Map_Receiver(Map_Mesh.Vertices[i], new Rhino.Geometry.Point3f((float)Map[s].Src.X, (float)Map[s].Src.Y, (float)Map[s].Src.Z), Direct_Time, Rho_C, i, SampleRate, SampleCT, Directional);
}
else
{
Rhino.Geometry.Point3d RecLoc = Map_Mesh.Faces.GetFaceCenter(i);
Map[s].Rec_List[i] = new Mapping.PachMapReceiver.Map_Receiver(new Rhino.Geometry.Point3f((float)RecLoc.X, (float)RecLoc.Y, (float)RecLoc.Z), new Rhino.Geometry.Point3f((float)Map[s].Src.X, (float)Map[s].Src.Y, (float)Map[s].Src.Z), Direct_Time, Rho_C, i, SampleRate, SampleCT, Directional);
}
for (int Octave = 0; Octave < 8; Octave++)
{
//Write Octave (int)
int Oct_out = (int)sr.ReadUInt32();
if (Oct_out != Octave) throw new Exception(string.Format("Octave {0} Expected", Octave));
double[] Hist = Map[s].Rec_List[i].GetEnergyHistogram(Octave);
if (Directional)
{
示例4: Deserialize
public static PollChunksRequestMessage Deserialize(byte[] bytes)
{
Guid id;
Guid chunkIDs;
bool requestData;
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
id = new Guid (BR.ReadBytes (16));
chunkIDs = new Guid (BR.ReadBytes (16));
requestData = BR.ReadBoolean ();
}
}
return new PollChunksRequestMessage (id, chunkIDs, requestData);
}
示例5: Deserialize
public static PollNewChunksRequestMessage Deserialize(byte[] bytes)
{
Guid id;
bool metaOnly;
using (System.IO.MemoryStream MS = new System.IO.MemoryStream (bytes, false)) {
using (System.IO.BinaryReader BR = new System.IO.BinaryReader (MS)) {
id = new Guid (BR.ReadBytes (16));
metaOnly = BR.ReadBoolean ();
}
}
return new PollNewChunksRequestMessage (id, metaOnly);
}
示例6: 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 ());
}
}
}
示例7: LoadGroupObject
private void LoadGroupObject(BinaryReader reader, int key, Dictionary<int, object> objects)
{
var comparer = ObjectReferenceEqualityComparer<object>.Default;
int typeKey = reader.ReadInt32();
if (typeKey == 0)
{
// this is a string, nothing more to load
reader.ReadString();
return;
}
string typeName = (string)objects[typeKey];
if (typeName == typeof(bool).FullName)
{
// nothing more to load
reader.ReadBoolean();
return;
}
else if (typeName == typeof(TemplateToken).FullName || typeName == typeof(CommonToken).FullName)
{
// nothing more to load
int channel = reader.ReadInt32();
int charPositionInLine = reader.ReadInt32();
int line = reader.ReadInt32();
int startIndex = reader.ReadInt32();
int stopIndex = reader.ReadInt32();
string text = reader.ReadString();
int tokenIndex = reader.ReadInt32();
int type = reader.ReadInt32();
return;
}
else if (typeName == typeof(CompiledTemplate).FullName)
{
CompiledTemplate compiledTemplate = (CompiledTemplate)objects[key];
string name = reader.ReadString();
string prefix = reader.ReadString();
string template = reader.ReadString();
int templateDefStartTokenObject = reader.ReadInt32();
bool hasFormalArgs = reader.ReadBoolean();
int nativeGroupObject = reader.ReadInt32();
bool isRegion = reader.ReadBoolean();
Template.RegionType regionDefType = (Template.RegionType)reader.ReadInt32();
bool isAnonSubtemplate = reader.ReadBoolean();
compiledTemplate.TemplateDefStartToken = (IToken)objects[templateDefStartTokenObject];
compiledTemplate.NativeGroup = this;
int formalArgsLength = reader.ReadInt32();
if (formalArgsLength >= 0)
{
List<FormalArgument> formalArguments = new List<FormalArgument>(formalArgsLength);
for (int i = 0; i < formalArgsLength; i++)
{
int formalArgObject = reader.ReadInt32();
formalArguments.Add((FormalArgument)objects[formalArgObject]);
}
compiledTemplate.FormalArguments = formalArguments;
}
int stringsLength = reader.ReadInt32();
for (int i = 0; i < stringsLength; i++)
reader.ReadString();
int instrsLength = reader.ReadInt32();
if (instrsLength >= 0)
reader.ReadBytes(instrsLength);
int codeSize = reader.ReadInt32();
int sourceMapLength = reader.ReadInt32();
for (int i = 0; i < sourceMapLength; i++)
{
int start = reader.ReadInt32();
int length = reader.ReadInt32();
}
return;
}
else if (typeName == typeof(FormalArgument).FullName)
{
FormalArgument formalArgument = (FormalArgument)objects[key];
string name = reader.ReadString();
int index = reader.ReadInt32();
IToken defaultValueToken = (IToken)objects[reader.ReadInt32()];
int defaultValueObject = reader.ReadInt32();
int compiledDefaultValue = reader.ReadInt32();
formalArgument.DefaultValue = objects[defaultValueObject];
formalArgument.CompiledDefaultValue = (CompiledTemplate)objects[compiledDefaultValue];
}
else if (typeName == typeof(Template).FullName)
{
Template template = (Template)objects[key];
int implObject = reader.ReadInt32();
template.impl = (CompiledTemplate)objects[implObject];
//.........这里部分代码省略.........
示例8: CreateGroupObject
private object CreateGroupObject(BinaryReader reader, int key, Dictionary<int, object> objects)
{
var comparer = ObjectReferenceEqualityComparer<object>.Default;
int typeKey = reader.ReadInt32();
if (typeKey == 0)
{
// this is a string
return reader.ReadString();
}
string typeName = (string)objects[typeKey];
if (typeName == typeof(bool).FullName)
{
return reader.ReadBoolean();
}
else if (typeName == typeof(TemplateToken).FullName || typeName == typeof(CommonToken).FullName)
{
int channel = reader.ReadInt32();
int charPositionInLine = reader.ReadInt32();
int line = reader.ReadInt32();
int startIndex = reader.ReadInt32();
int stopIndex = reader.ReadInt32();
string text = reader.ReadString();
int tokenIndex = reader.ReadInt32();
int type = reader.ReadInt32();
CommonToken token = new CommonToken(type, text)
{
Channel = channel,
CharPositionInLine = charPositionInLine,
Line = line,
StartIndex = startIndex,
StopIndex = stopIndex,
TokenIndex = tokenIndex,
};
return token;
}
else if (typeName == typeof(CompiledTemplate).FullName)
{
CompiledTemplate compiledTemplate = new CompiledTemplate();
compiledTemplate.Name = reader.ReadString();
compiledTemplate.Prefix = reader.ReadString();
compiledTemplate.Template = reader.ReadString();
int templateDefStartTokenObject = reader.ReadInt32();
compiledTemplate.HasFormalArgs = reader.ReadBoolean();
int nativeGroupObject = reader.ReadInt32();
compiledTemplate.IsRegion = reader.ReadBoolean();
compiledTemplate.RegionDefType = (Template.RegionType)reader.ReadInt32();
compiledTemplate.IsAnonSubtemplate = reader.ReadBoolean();
int formalArgsLength = reader.ReadInt32();
if (formalArgsLength > 0)
{
for (int i = 0; i < formalArgsLength; i++)
{
int formalArgObject = reader.ReadInt32();
}
}
int stringsLength = reader.ReadInt32();
if (stringsLength >= 0)
{
compiledTemplate.strings = new string[stringsLength];
for (int i = 0; i < stringsLength; i++)
compiledTemplate.strings[i] = reader.ReadString();
}
int instrsLength = reader.ReadInt32();
if (instrsLength >= 0)
compiledTemplate.instrs = reader.ReadBytes(instrsLength);
compiledTemplate.codeSize = reader.ReadInt32();
int sourceMapLength = reader.ReadInt32();
if (sourceMapLength >= 0)
{
compiledTemplate.sourceMap = new Interval[sourceMapLength];
for (int i = 0; i < sourceMapLength; i++)
{
int start = reader.ReadInt32();
int length = reader.ReadInt32();
if (length >= 0)
compiledTemplate.sourceMap[i] = new Interval(start, length);
}
}
return compiledTemplate;
}
else if (typeName == typeof(FormalArgument).FullName)
{
string name = reader.ReadString();
int index = reader.ReadInt32();
IToken defaultValueToken = (IToken)objects[reader.ReadInt32()];
int defaultValueObject = reader.ReadInt32();
int compiledDefaultValue = reader.ReadInt32();
FormalArgument formalArgument = new FormalArgument(name, defaultValueToken);
formalArgument.Index = index;
//.........这里部分代码省略.........
示例9: 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 ());
}
}
}
示例10: 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);
}
}
}