Here are the examples of the csharp api System.IO.Stream.ReadValueU8() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
19
Source : Program.cs
with MIT License
from sa68ru
with MIT License
from sa68ru
public bool ReadAsBinary(Stream input)
{
this.Children = new List<KeyValue>();
try
{
while (true)
{
var type = (KeyValueType)input.ReadValueU8();
if (type == KeyValueType.End)
{
break;
}
var current = new KeyValue
{
Type = type,
Name = input.ReadStringUnicode(),
};
switch (type)
{
case KeyValueType.None:
{
current.ReadAsBinary(input);
break;
}
case KeyValueType.String:
{
current.Valid = true;
current.Value = input.ReadStringUnicode();
break;
}
case KeyValueType.WideString:
{
throw new FormatException("wstring is unsupported");
}
case KeyValueType.Int32:
{
current.Valid = true;
current.Value = input.ReadValueS32();
break;
}
case KeyValueType.UInt64:
{
current.Valid = true;
current.Value = input.ReadValueU64();
break;
}
case KeyValueType.Float32:
{
current.Valid = true;
current.Value = input.ReadValueF32();
break;
}
case KeyValueType.Color:
{
current.Valid = true;
current.Value = input.ReadValueU32();
break;
}
case KeyValueType.Pointer:
{
current.Valid = true;
current.Value = input.ReadValueU32();
break;
}
default:
{
throw new FormatException();
}
}
if (input.Position >= input.Length)
{
throw new FormatException();
}
this.Children.Add(current);
}
this.Valid = true;
return input.Position == input.Length;
}
catch (Exception)
{
return false;
}
}