Here are the examples of the csharp api System.IO.Stream.ReadInt32() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6 Examples
19
Source : KeyValue.cs
with MIT License
from Astropilot
with MIT License
from Astropilot
private static bool TryReadAsBinaryCore(Stream input, KeyValue current, KeyValue parent)
{
current.Children = new List<KeyValue>();
while (true)
{
var type = (Type)input.ReadByte();
if (type == Type.End)
{
break;
}
current.Name = input.ReadNullTermString(Encoding.UTF8);
switch (type)
{
case Type.None:
{
var child = new KeyValue();
var didReadChild = TryReadAsBinaryCore(input, child, current);
if (!didReadChild)
{
return false;
}
break;
}
case Type.String:
{
current.Value = input.ReadNullTermString(Encoding.UTF8);
break;
}
case Type.WideString:
{
System.Diagnostics.Debug.WriteLine("KeyValue", "Encountered WideString type when parsing binary KeyValue, which is unsupported. Returning false.");
return false;
}
case Type.Int32:
case Type.Color:
case Type.Pointer:
{
current.Value = Convert.ToString(input.ReadInt32());
break;
}
case Type.UInt64:
{
current.Value = Convert.ToString(input.ReadUInt64());
break;
}
case Type.Float32:
{
current.Value = Convert.ToString(input.ReadFloat());
break;
}
default:
{
return false;
}
}
if (parent != null)
{
parent.Children.Add(current);
}
current = new KeyValue();
}
return true;
}
19
Source : StreamExt.cs
with GNU General Public License v3.0
from Fe7n
with GNU General Public License v3.0
from Fe7n
public static uint ReadUInt32(this Stream s)
{
return (uint)s.ReadInt32();
}
19
Source : StreamExt.cs
with GNU General Public License v3.0
from Fe7n
with GNU General Public License v3.0
from Fe7n
public static byte[] ReadBytesWithLength(this Stream s)
{
int count = s.ReadInt32();
return s.ReadBytes(count);
}
19
Source : StreamCommunicator.cs
with MIT License
from microsoft
with MIT License
from microsoft
public static byte[] ReadByteArray(this Stream stream)
{
int arraySize = stream.ReadInt32();
var array = new byte[arraySize];
if (arraySize > 0)
{
stream.ReadAllRequiredBytes(array, 0, array.Length);
}
return array;
}
19
Source : StreamExtensions.cs
with MIT License
from Shenmue-Mods
with MIT License
from Shenmue-Mods
public static string ReadString(this Stream stream, bool HasLengthWritten = false)
{
if (stream == null || !stream.CanRead)
throw new IOException("Stream cannot be read.");
int length = -1;
List<char> chars = new List<char>();
if (HasLengthWritten)
{
length = stream.ReadInt32();
for (int i = 0; i < length; i++)
chars.Add((char)stream.ReadByte());
}
else
{
char c = 'a';
while ((c = (char)stream.ReadByte()) != '\0')
{
chars.Add(c);
}
}
return new String(chars.ToArray());
}
19
Source : StreamExtensions.cs
with Apache License 2.0
from Xeeynamo
with Apache License 2.0
from Xeeynamo
public static int PeekInt32(this Stream stream) => stream.Peek(x => x.ReadInt32());