本文整理汇总了C#中Stream.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# Stream.ReadString方法的具体用法?C# Stream.ReadString怎么用?C# Stream.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadFrom
public virtual bool LoadFrom(Stream stream)
{
uint count = stream.ReadUInt();
for (int i = 0; i < count; i++)
{
var key = stream.ReadString();
var val = stream.ReadString();
KeyValues.Add(key, val);
}
return true;
}
示例2: ParseRiff
private void ParseRiff(Stream Stream)
{
if (Stream.ReadString(4) != "WAVE") throw (new InvalidDataException("Not a RIFF.WAVE File"));
while (!Stream.Eof())
{
var ChunkType = Stream.ReadString(4);
var ChunkSize = new BinaryReader(Stream).ReadUInt32();
var ChunkStream = Stream.ReadStream(ChunkSize);
HandleChunkInternal(ChunkType, ChunkStream);
}
}
示例3: Check
/* Check to see if this is a GIM */
public override bool Check(ref Stream input, string filename)
{
try
{
return (input.ReadString(0x0, 12, false) == GraphicHeader.MIG ||
input.ReadString(0x0, 12, false) == GraphicHeader.GIM);
}
catch
{
return false;
}
}
示例4: Check
/* Checks to see if the input stream is a SNT archive */
public override bool Check(ref Stream input, string filename)
{
try
{
return ((input.ReadString(0x0, 4) == ArchiveHeader.NSIF &&
input.ReadString(0x20, 4) == ArchiveHeader.NSTL) ||
(input.ReadString(0x0, 4) == ArchiveHeader.NUIF &&
input.ReadString(0x20, 4) == ArchiveHeader.NUTL));
}
catch
{
return false;
}
}
示例5: ReadBody
public static ForwardedSubscriptionRequest ReadBody(Stream stream)
{
var clientId = stream.ReadInt32();
var topic = stream.ReadString();
var isAdd = stream.ReadBoolean();
return new ForwardedSubscriptionRequest(clientId, topic, isAdd);
}
示例6: GetFileList
/* Get the offsets, lengths, and filenames of all the files */
public override ArchiveFileList GetFileList(ref Stream data)
{
try
{
/* Get the number of files */
uint files = data.ReadUInt(0x0);
/* Create the array of files now */
ArchiveFileList fileList = new ArchiveFileList(files);
/* Now we can get the file offsets, lengths, and filenames */
for (uint i = 0; i < files; i++)
{
fileList.Entries[i] = new ArchiveFileList.Entry(
data.ReadUInt(0x4 + (i * 0x2C)), // Offset
data.ReadUInt(0x8 + (i * 0x2C)), // Length
data.ReadString(0xC + (i * 0x2C), 36) // Filename
);
}
return fileList;
}
catch
{
return null;
}
}
示例7: Deserialize
public void Deserialize(Stream input)
{
var magic = input.ReadValueU32(this.LittleEndian);
if (magic != 0x54414653)
throw new NotSupportedException("Bad magic number");
this.Unknown04 = input.ReadValueU32(this.LittleEndian);
this.NumberOfFiles = input.ReadValueU32(this.LittleEndian);
var count = input.ReadValueU32(this.LittleEndian);
this.Unknown10 = input.ReadValueU32(this.LittleEndian);
this.BasePath = input.ReadString(32, true, Encoding.ASCII);
this.Entries.Clear();
for (uint i = 0; i < count; i++)
{
var entry = new Big.EntryV2();
entry.NameHash = input.ReadValueU32(this.LittleEndian);
entry.Locale = input.ReadValueU32(this.LittleEndian);
entry.Size = input.ReadValueU32(this.LittleEndian);
var offset = input.ReadValueU32(this.LittleEndian);
entry.Offset = offset & 0xFFFFFF00;
entry.File = offset & 0xFF;
this.Entries.Add(entry);
}
}
示例8: ReadChunk
public static BodyChunk ReadChunk(string RawBody, Stream ResponseStream)
{
if (RawBody == "0\r\n\r\n")
return new BodyChunk("", true);
var bodyIndex = RawBody.IndexOf("\r\n");
var chunkLength = int.Parse(RawBody.Remove(bodyIndex), System.Globalization.NumberStyles.HexNumber);
var bodyLength = RawBody.Length - bodyIndex + 2;
while (bodyLength <= chunkLength)
{
var resp = ResponseStream.ReadString(8192 * 4);
bodyLength += resp.Length;
RawBody += resp;
}
var body = RawBody.Substring(bodyIndex + 2, chunkLength);
var end = bodyIndex + 2 + chunkLength;
var tail = RawBody.Substring(end);
return new BodyChunk(body, tail.Contains("0"));
}
示例9: ReadFrom
public void ReadFrom(Stream stream)
{
int numMaterials = stream.ReadInt32();
Layers = new MyMaterialLayer[numMaterials];
for (int i = 0; i < numMaterials; ++i)
{
Layers[i] = new MyMaterialLayer();
Layers[i].StartHeight = stream.ReadFloat();
Layers[i].EndHeight = stream.ReadFloat();
Layers[i].StartAngle = stream.ReadFloat();
Layers[i].EndAngle = stream.ReadFloat();
Layers[i].HeightStartDeviation = stream.ReadFloat();
Layers[i].AngleStartDeviation = stream.ReadFloat();
Layers[i].HeightEndDeviation = stream.ReadFloat();
Layers[i].AngleEndDeviation = stream.ReadFloat();
Layers[i].MaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition(stream.ReadString());
}
int numOreProbabilities = stream.ReadInt32();
OreProbabilities = new MyOreProbability[numOreProbabilities];
for (int i = 0; i < numOreProbabilities; ++i)
{
OreProbabilities[i] = new MyOreProbability();
OreProbabilities[i].CummulativeProbability = stream.ReadFloat();
OreProbabilities[i].OreName = stream.ReadString();
}
OreStartDepth = stream.ReadFloat();
OreEndDepth = stream.ReadFloat();
}
示例10: Read
public static PlainTextExtension Read(Stream stream)
{
var blockSize = stream.ReadByte();
if (blockSize != BlockSize)
{
throw new GifException("Plain text extension data format error");
}
var result = new PlainTextExtension
{
TextGridLeftPosition = stream.ReadShort(),
TextGridTopPosition = stream.ReadShort(),
TextGridWidth = stream.ReadShort(),
TextGridHeight = stream.ReadShort(),
CharacterCellWidth = (byte) stream.ReadByte(),
CharacterCellHeight = (byte) stream.ReadByte(),
TextForegroundColorIndex = (byte) stream.ReadByte(),
TextBackgroundColorIndex = (byte) stream.ReadByte(),
PlainTextData = new List<string>()
};
blockSize = stream.ReadByte();
while (blockSize > 0)
{
var plainTextData = stream.ReadString(blockSize);
result.PlainTextData.Add(plainTextData);
blockSize = stream.ReadByte();
}
return result;
}
示例11: ParseFile
private void ParseFile(Stream Stream)
{
if (Stream.ReadString(4) != "RIFF") throw (new InvalidDataException("Not a RIFF File"));
var RiffSize = new BinaryReader(Stream).ReadUInt32();
var RiffStream = Stream.ReadStream(RiffSize);
ParseRiff(RiffStream);
}
示例12: ReadString
private static string ReadString(Stream input)
{
var length = input.ReadValueU32();
if (length >= 1024)
{
throw new InvalidOperationException();
}
return input.ReadString(length, true, Encoding.ASCII);
}
示例13: Check
/* Checks to see if the input stream is a MRG archive */
public override bool Check(ref Stream input, string filename)
{
try
{
return (input.ReadString(0x0, 4) == ArchiveHeader.MRG);
}
catch
{
return false;
}
}
示例14: Deserialize
public object Deserialize(Stream stream){
int count = (int)ZigZag.DeserializeUInt32 (stream);
var types = new TypeMap ();
while(count-- != 0) {
uint tag = ZigZag.DeserializeUInt32 (stream);
var typeName = stream.ReadString ();
var type = this.typeNames.GetType (typeName);
types.Add(tag, typeName, type);
}
return types;
}
示例15: Check
// Check
public override bool Check(ref Stream data, string filename)
{
try
{
return (data.ReadString(0x0, 4) == "LZ01");
}
catch
{
return false;
}
}