本文整理汇总了C#中System.IO.BinaryReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryReader.ReadString方法的具体用法?C# BinaryReader.ReadString怎么用?C# BinaryReader.ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadV1
void LoadV1(BinaryReader binread)
{
var strread = new StringReader(binread.ReadString());
var xmlread = XmlReader.Create(strread);
var xmlserializer = new XmlSerializer(engineStartParams.type);
engineStartParams.Load(xmlserializer.Deserialize(xmlread));
strread.Close ();
xmlread.Close ();
int count = binread.ReadInt32();
for(int i=0;i<count;i++)
{
var enabled = binread.ReadBoolean();
var typestr = binread.ReadString();
var type = Type.GetType (typestr);
if(type == null)
{
binread.ReadString(); // can't find type, so just read and throw away
continue;
}
var xmlserializer2 = new XmlSerializer(type);
strread = new StringReader(binread.ReadString());
xmlread = XmlReader.Create(strread);
customGameStartParams[type].Load(xmlserializer2.Deserialize(xmlread));
strread.Close ();
xmlread.Close ();
customGameStartParams[type].enabled = enabled;
}
binread.Close();
xmlread.Close();
}
示例2: 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;
}
示例3: SetDataFrom
public void SetDataFrom(BinaryReader reader)
{
var tests = new List<LiveTestStatus>();
CurrentAssembly = reader.ReadString();
CurrentTest = reader.ReadString();
TotalNumberOfTests = reader.ReadInt32();
TestsCompleted = reader.ReadInt32();
var count = reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var test = new LiveTestStatus("", null);
test.SetDataFrom(reader);
tests.Add(test);
}
_failedTest = tests.ToArray();
tests = new List<LiveTestStatus>();
count = reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var test = new LiveTestStatus("", null);
test.SetDataFrom(reader);
tests.Add(test);
}
_failedButNowPassing = tests.ToArray();
}
示例4: readDataFrom
public void readDataFrom(BinaryReader r)
{
this.Manufacturer = r.ReadString();
this.Model = r.ReadString();
this.PhoneNumber = r.ReadString();
this.HasCord = r.ReadBoolean();
}
示例5: 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();
}
}
示例6: ReadFromFile
public static void ReadFromFile(IndexUnit indexPage, BinaryReader reader)
{
long initPos = reader.Seek(100L + (indexPage.UnitID * 0x1000L));
if (reader.ReadByte() != 2)
{
throw new FileDBException("PageID {0} is not a Index Page", new object[] { indexPage.UnitID });
}
indexPage.NextUnitID = reader.ReadUInt32();
indexPage.NodeIndex = reader.ReadByte();
reader.Seek(initPos + 0x2eL);
for (int i = 0; i <= indexPage.NodeIndex; i++)
{
IndexNode node = indexPage.Nodes[i];
node.ID = reader.ReadGuid();
node.IsDeleted = reader.ReadBoolean();
node.Right.Index = reader.ReadByte();
node.Right.PageID = reader.ReadUInt32();
node.Left.Index = reader.ReadByte();
node.Left.PageID = reader.ReadUInt32();
node.DataPageID = reader.ReadUInt32();
node.FileName = reader.ReadString(0x29);
node.FileExtension = reader.ReadString(5);
node.FileLength = reader.ReadUInt32();
}
}
示例7: Deserialize
public virtual AntiForgeryData Deserialize(string serializedToken)
{
if (String.IsNullOrEmpty(serializedToken))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "serializedToken");
}
try
{
using (MemoryStream stream = new MemoryStream(Decoder(serializedToken)))
{
using (BinaryReader reader = new BinaryReader(stream))
{
return new AntiForgeryData
{
Salt = reader.ReadString(),
Value = reader.ReadString(),
CreationDate = new DateTime(reader.ReadInt64()),
Username = reader.ReadString()
};
}
}
}
catch
{
throw new HttpAntiForgeryException(WebPageResources.AntiForgeryToken_ValidationFailed);
}
}
示例8: ReadFrom
public static TestResultData ReadFrom(BinaryReader reader)
{
var displayName = reader.ReadString();
var state = (TestState)reader.ReadInt32();
var output = reader.ReadString();
return new TestResultData(displayName, state, output);
}
示例9: Shader
internal Shader(GraphicsDevice device, BinaryReader reader)
{
this.GraphicsDevice = device;
this.Stage = reader.ReadBoolean() ? ShaderStage.Vertex : ShaderStage.Pixel;
int count = (int) reader.ReadUInt16();
byte[] bytes = reader.ReadBytes(count);
int length1 = (int) reader.ReadByte();
this.Samplers = new SamplerInfo[length1];
for (int index = 0; index < length1; ++index)
{
this.Samplers[index].type = (SamplerType) reader.ReadByte();
this.Samplers[index].index = (int) reader.ReadByte();
this.Samplers[index].name = reader.ReadString();
this.Samplers[index].parameter = (int) reader.ReadByte();
}
int length2 = (int) reader.ReadByte();
this.CBuffers = new int[length2];
for (int index = 0; index < length2; ++index)
this.CBuffers[index] = (int) reader.ReadByte();
this._glslCode = Encoding.ASCII.GetString(bytes);
this.HashKey = Hash.ComputeHash(bytes);
int length3 = (int) reader.ReadByte();
this._attributes = new Shader.Attribute[length3];
for (int index = 0; index < length3; ++index)
{
this._attributes[index].name = reader.ReadString();
this._attributes[index].usage = (VertexElementUsage) reader.ReadByte();
this._attributes[index].index = (int) reader.ReadByte();
this._attributes[index].format = reader.ReadInt16();
}
}
示例10: Deserialize
public static Auction Deserialize(Stream dataStream)
{
var reader = new BinaryReader(dataStream);
var auction = new Auction();
auction.Id = reader.ReadInt64();
auction.ItemId = reader.ReadInt64();
auction.PlacedBy = reader.ReadString();
auction.Realm = reader.ReadString();
auction.CurrentBid = reader.ReadInt64();
auction.Buyout = reader.ReadInt64();
auction.Quantity = reader.ReadInt32();
auction.Random = reader.ReadInt64();
auction.Seed = reader.ReadInt64();
auction.GenerationContext = reader.ReadInt32();
auction.PetSpeciesId = reader.ReadInt32();
auction.PetBreedId = reader.ReadInt32();
auction.PetLevel = reader.ReadInt32();
auction.PetQualityId = reader.ReadInt32();
if (auction.PetSpeciesId == -1) auction.PetSpeciesId = null;
if (auction.PetBreedId == -1) auction.PetBreedId = null;
if (auction.PetLevel == -1) auction.PetLevel = null;
if (auction.PetQualityId == -1) auction.PetQualityId = null;
return auction;
}
示例11: LoadBooks
public IEnumerable<Book> LoadBooks()
{
List<Book> books = new List<Book>();
try
{
using (FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read))
{
using (BinaryReader bw = new BinaryReader(fs))
{
long position = bw.BaseStream.Position;
while (position < bw.BaseStream.Length)
{
Book book = new Book(bw.ReadString(), bw.ReadString(), bw.ReadString(), bw.ReadInt32(), bw.ReadInt32(), bw.ReadInt32());
books.Add(book);
position = bw.BaseStream.Position;
}
}
}
}
catch (Exception e)
{
books.Clear();
books.TrimExcess();
throw new IOException("Error while loading books from file.", e);
}
return books;
}
示例12: Main
static void Main(string[] args)
{
int serverPort = 7000;
IPAddress serverIPAddress = IPAddress.Loopback; // il localhost
var tcpClient = new TcpClient();
// la connessione UDP va definita usando esplicitamente la classe socket
tcpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), serverPort));
using (Stream stream = tcpClient.GetStream())
using (BinaryReader reader = new BinaryReader(stream))
using (BinaryWriter writer = new BinaryWriter(stream)) {
string domanda = reader.ReadString();
Console.WriteLine(domanda);
string risposta = Console.ReadLine();
int rispostaInt;
if (Int32.TryParse(risposta, out rispostaInt)){
writer.Write(rispostaInt);
}
string risultato = reader.ReadString();
Console.WriteLine("La tua risposta e' {0}", risultato);
}
}
示例13: AuthenticationCookie
private AuthenticationCookie(byte[] data)
{
using (var memoryStream = new MemoryStream(data))
{
using (var binaryReader = new BinaryReader(memoryStream))
{
_cookieType = binaryReader.ReadInt16();
_id = new Guid(binaryReader.ReadBytes(16));
_persistent = binaryReader.ReadBoolean();
_issueDate = DateTime.FromBinary(binaryReader.ReadInt64());
_name = binaryReader.ReadString();
var rolesLength = binaryReader.ReadInt16();
_roles = new string[rolesLength];
for (int i = 0; i < _roles.Length; i++)
{
_roles[i] = binaryReader.ReadString();
}
var tagLength = binaryReader.ReadInt16();
if (tagLength == 0)
{
_tag = null;
}
else
{
_tag = binaryReader.ReadBytes(tagLength);
}
}
}
}
示例14: TestWrite
public void TestWrite()
{
PostingListEncoder decoder = new PostingListEncoder();
SpimiBlockWriter writer = new SpimiBlockWriter();
writer.AddPosting("bTerm", DocA);
writer.AddPosting("aTerm", DocA);
writer.AddPosting("aTerm", DocB);
string filePath = writer.FlushToFile();
using (FileStream file = File.Open(filePath, FileMode.Open))
{
BinaryReader reader = new BinaryReader(file);
Assert.AreEqual(2, reader.ReadInt32());
Assert.AreEqual("aTerm", reader.ReadString());
IList<Posting> postings = new List<Posting>();
postings.Add(new Posting(DocA, 1));
postings.Add(new Posting(DocB, 1));
IList<Posting> readPostings = decoder.read(reader);
for (int i = 0; i < postings.Count; i++ )
{
readPostings[i].Equals(postings[i]);
}
Assert.AreEqual("bTerm", reader.ReadString());
readPostings = decoder.read(reader);
Assert.AreEqual(new Posting(DocA, 1), readPostings[0]);
}
}
示例15: ReadCustomData
internal static void ReadCustomData(Player player, BinaryReader reader)
{
int count = reader.ReadUInt16();
for (int k = 0; k < count; k++)
{
string modName = reader.ReadString();
string name = reader.ReadString();
byte[] data = reader.ReadBytes(reader.ReadUInt16());
Mod mod = ModLoader.GetMod(modName);
ModPlayer modPlayer = mod == null ? null : player.GetModPlayer(mod, name);
if (modPlayer != null)
{
using (MemoryStream stream = new MemoryStream(data))
{
using (BinaryReader customReader = new BinaryReader(stream))
{
modPlayer.LoadCustomData(customReader);
}
}
if (modName == "ModLoader" && name == "MysteryPlayer")
{
((MysteryPlayer)modPlayer).RestoreData(player);
}
}
else
{
ModPlayer mystery = player.GetModPlayer(ModLoader.GetMod("ModLoader"), "MysteryPlayer");
((MysteryPlayer)mystery).AddData(modName, name, data);
}
}
}