本文整理汇总了C#中ProtoBuf.ProtoReader.CreateWireTypeException方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoReader.CreateWireTypeException方法的具体用法?C# ProtoReader.CreateWireTypeException怎么用?C# ProtoReader.CreateWireTypeException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoBuf.ProtoReader
的用法示例。
在下文中一共展示了ProtoReader.CreateWireTypeException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartSubItem
public static SubItemToken StartSubItem(ProtoReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
WireType wireType = reader.wireType;
if (wireType != WireType.String)
{
if (wireType != WireType.StartGroup)
{
throw reader.CreateWireTypeException();
}
reader.wireType = WireType.None;
reader.depth++;
return new SubItemToken(-reader.fieldNumber);
}
else
{
int num = (int)reader.ReadUInt32Variant(false);
if (num < 0)
{
throw ProtoReader.AddErrorData(new InvalidOperationException(), reader);
}
int value = reader.blockEnd;
reader.blockEnd = reader.position + num;
reader.depth++;
return new SubItemToken(value);
}
}
示例2: AppendBytes
public static byte[] AppendBytes(byte[] value, ProtoReader reader)
{
if (reader == null)
{
throw new ArgumentNullException("reader");
}
WireType wireType = reader.wireType;
if (wireType != WireType.String)
{
throw reader.CreateWireTypeException();
}
int i = (int)reader.ReadUInt32Variant(false);
reader.wireType = WireType.None;
if (i == 0)
{
return (value != null) ? value : ProtoReader.EmptyBlob;
}
int num;
if (value == null || value.Length == 0)
{
num = 0;
value = new byte[i];
}
else
{
num = value.Length;
byte[] array = new byte[value.Length + i];
Helpers.BlockCopy(value, 0, array, 0, value.Length);
value = array;
}
reader.position += i;
while (i > reader.available)
{
if (reader.available > 0)
{
Helpers.BlockCopy(reader.ioBuffer, reader.ioIndex, value, num, reader.available);
i -= reader.available;
num += reader.available;
reader.ioIndex = (reader.available = 0);
}
int num2 = (i <= reader.ioBuffer.Length) ? i : reader.ioBuffer.Length;
if (num2 > 0)
{
reader.Ensure(num2, true);
}
}
if (i > 0)
{
Helpers.BlockCopy(reader.ioBuffer, reader.ioIndex, value, num, i);
reader.ioIndex += i;
reader.available -= i;
}
return value;
}