本文整理汇总了C#中ProtoReader.TryReadFieldHeader方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoReader.TryReadFieldHeader方法的具体用法?C# ProtoReader.TryReadFieldHeader怎么用?C# ProtoReader.TryReadFieldHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoReader
的用法示例。
在下文中一共展示了ProtoReader.TryReadFieldHeader方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public override object Read(object value, ProtoReader source)
{
object obj = this.builderFactory.Invoke(null, null);
int fieldNumber = source.FieldNumber;
object[] array = new object[1];
if (base.AppendToCollection && value != null && ((IList)value).Count != 0)
{
if (this.addRange != null)
{
array[0] = value;
this.addRange.Invoke(obj, array);
}
else
{
foreach (object current in ((IList)value))
{
array[0] = current;
this.add.Invoke(obj, array);
}
}
}
if (this.packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
while (ProtoReader.HasSubValue(this.packedWireType, source))
{
array[0] = this.Tail.Read(null, source);
this.add.Invoke(obj, array);
}
ProtoReader.EndSubItem(token, source);
}
else
{
do
{
array[0] = this.Tail.Read(null, source);
this.add.Invoke(obj, array);
}
while (source.TryReadFieldHeader(fieldNumber));
}
return this.finish.Invoke(obj, null);
}
示例2: Read
public override object Read(object value, ProtoReader source)
{
object builderInstance = builderFactory.Invoke(null, null);
int field = source.FieldNumber;
object[] args = new object[1];
if (AppendToCollection && value != null && ((IList)value).Count != 0)
{
if(addRange !=null)
{
args[0] = value;
addRange.Invoke(builderInstance, args);
}
else
{
foreach(object item in (IList)value)
{
args[0] = item;
add.Invoke(builderInstance, args);
}
}
}
if (packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
while (ProtoReader.HasSubValue(packedWireType, source))
{
args[0] = Tail.Read(null, source);
add.Invoke(builderInstance, args);
}
ProtoReader.EndSubItem(token, source);
}
else
{
do
{
args[0] = Tail.Read(null, source);
add.Invoke(builderInstance, args);
} while (source.TryReadFieldHeader(field));
}
return finish.Invoke(builderInstance, null);
}
示例3: Read
public override object Read(object value, ProtoReader source)
{
int field = source.FieldNumber;
BasicList list = new BasicList();
if (packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
while (ProtoReader.HasSubValue(packedWireType, source))
{
list.Add(Tail.Read(null, source));
}
ProtoReader.EndSubItem(token, source);
}
else
{
do
{
list.Add(Tail.Read(null, source));
} while (source.TryReadFieldHeader(field));
}
int oldLen = AppendToCollection ? ((value == null ? 0 : ((Array)value).Length)) : 0;
Array result = Array.CreateInstance(itemType, oldLen + list.Count);
if (oldLen != 0) ((Array)value).CopyTo(result, 0);
list.CopyTo(result, oldLen);
return result;
}
示例4: Read
public override object Read(object value, ProtoReader source)
{
int field = source.FieldNumber;
object origValue = value;
if (value == null) value = Activator.CreateInstance(concreteType);
bool isList = IsList && !SuppressIList;
if (packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
if (isList)
{
IList list = (IList)value;
while (ProtoReader.HasSubValue(packedWireType, source))
{
list.Add(Tail.Read(null, source));
}
}
else {
object[] args = new object[1];
while (ProtoReader.HasSubValue(packedWireType, source))
{
args[0] = Tail.Read(null, source);
add.Invoke(value, args);
}
}
ProtoReader.EndSubItem(token, source);
}
else {
if (isList)
{
IList list = (IList)value;
do
{
list.Add(Tail.Read(null, source));
} while (source.TryReadFieldHeader(field));
}
else
{
object[] args = new object[1];
do
{
args[0] = Tail.Read(null, source);
add.Invoke(value, args);
} while (source.TryReadFieldHeader(field));
}
}
return origValue == value ? null : value;
}
示例5: Read
public override object Read(object value, ProtoReader source)
{
if (nested)
{
source.ReadFieldHeader();
}
int field = source.FieldNumber;
BasicList list = new BasicList();
if (packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
while (ProtoReader.HasSubValue(packedWireType, source))
{
list.Add(Tail.Read(null, source));
}
ProtoReader.EndSubItem(token, source);
int oldLen = AppendToCollection ? ((value == null ? 0 : ((Array)value).Length)) : 0;
Array result = Array.CreateInstance(itemType, oldLen + list.Count);
if (oldLen != 0) ((Array)value).CopyTo(result, 0);
list.CopyTo(result, oldLen);
return result;
}
else
{
bool readObject = true;
int arrayKey = 0;
value = value ?? Array.CreateInstance(itemType, 0);
if (AsReference)
{
int objectKey = source.ReadInt32();
if (objectKey > 0)
{
value = source.NetCache.GetKeyedObject(objectKey);
readObject = false;
}
else
{
bool dummy;
arrayKey = source.NetCache.AddObjectKey(value, out dummy);
}
}
else
{
bool isEmpty = source.ReadInt32() == 1;
if (isEmpty)
{
return value;
}
}
if (readObject)
{
while (source.TryReadFieldHeader(field))
{
list.Add(Tail.Read(null, source));
}
Array newArray = Array.CreateInstance(itemType, list.Count);
list.CopyTo(newArray, 0);
if (AsReference)
{
source.NetCache.UpdateKeyedObject(arrayKey, value, newArray);
}
value = newArray;
}
}
return value;
}
示例6: Read
public override object Read(object value, ProtoReader source)
{
int field = source.FieldNumber;
BasicList basicList = new BasicList();
if (this.packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
while (ProtoReader.HasSubValue(this.packedWireType, source))
{
basicList.Add(this.Tail.Read(null, source));
}
ProtoReader.EndSubItem(token, source);
}
else
{
do
{
basicList.Add(this.Tail.Read(null, source));
}
while (source.TryReadFieldHeader(field));
}
int num = (!this.AppendToCollection) ? 0 : ((value != null) ? ((Array)value).Length : 0);
Array array = Array.CreateInstance(this.itemType, num + basicList.Count);
if (num != 0)
{
((Array)value).CopyTo(array, 0);
}
basicList.CopyTo(array, num);
return array;
}
示例7: Read
public override object Read(object value, ProtoReader source)
{
int field = source.FieldNumber;
object obj = value;
if (value == null)
{
value = Activator.CreateInstance(this.concreteType);
}
bool flag = this.IsList && !this.SuppressIList;
if (this.packedWireType != WireType.None && source.WireType == WireType.String)
{
SubItemToken token = ProtoReader.StartSubItem(source);
if (flag)
{
IList list = (IList)value;
while (ProtoReader.HasSubValue(this.packedWireType, source))
{
list.Add(this.Tail.Read(null, source));
}
}
else
{
object[] array = new object[1];
while (ProtoReader.HasSubValue(this.packedWireType, source))
{
array[0] = this.Tail.Read(null, source);
this.add.Invoke(value, array);
}
}
ProtoReader.EndSubItem(token, source);
}
else if (flag)
{
IList list2 = (IList)value;
do
{
list2.Add(this.Tail.Read(null, source));
}
while (source.TryReadFieldHeader(field));
}
else
{
object[] array2 = new object[1];
do
{
array2[0] = this.Tail.Read(null, source);
this.add.Invoke(value, array2);
}
while (source.TryReadFieldHeader(field));
}
return (obj != value) ? value : null;
}