本文整理汇总了C#中ProtoBuf.ProtoReader.TryReadFieldHeader方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoReader.TryReadFieldHeader方法的具体用法?C# ProtoReader.TryReadFieldHeader怎么用?C# ProtoReader.TryReadFieldHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoBuf.ProtoReader
的用法示例。
在下文中一共展示了ProtoReader.TryReadFieldHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadSInstance
void ReadSInstance(ProtoReader reader, SInstance sInstance, CLS_Environment environment)
{
List<CLS_Content.Value> values;
List<string> keywords;
GetSortMembers(sInstance, out values, out keywords);
int fieldNumber = 0;
while ((fieldNumber = reader.ReadFieldHeader()) > 0)
{
Type memberT = values[fieldNumber - 1].type;
CLS_Content.Value memberV = values[fieldNumber - 1];
string sClassName = keywords[fieldNumber - 1];
if (memberT == null)
{
memberT = typeof(SInstance);
sClassName = ((SType)memberV.type).Name;
}
Type itemType = GetItemType(memberT);
if (itemType != null)
{
sClassName = sInstance.type.members[sClassName].type.keyword;
// 数组判断
if (memberT.IsArray)
{
string itemClass = sClassName.Substring(0, sClassName.Length - 2); // 从 xxx[] 中提取xxx
BasicList list = new BasicList();
do
{
list.Add(ReadField(reader, itemType, itemClass, environment));
} while (reader.TryReadFieldHeader(fieldNumber));
Array result = Array.CreateInstance(itemType, list.Count);
list.CopyTo(result, 0);
memberV.value = result;
}
// 列表判断
else
{
string itemClass = sClassName.Substring(5, sClassName.Length - 6); // 从 List<xxx> 中提取xxx
ICLS_Type iType = environment.GetTypeByKeywordQuiet(sClassName);
CLS_Content content = CLS_Content.NewContent(environment);
memberV.value = iType.function.New(content, m_emptyParams).value;
CLS_Content.PoolContent(content);
IList list = (IList)memberV.value;
do
{
list.Add(ReadField(reader, itemType, itemClass, environment));
} while (reader.TryReadFieldHeader(fieldNumber));
}
}
else
{
memberV.value = ReadField(reader, memberT, sClassName, environment);
}
}
}
示例2: Read
/// <summary>
/// The read.
/// </summary>
/// <param name="mxMessage">
/// The mx message.
/// </param>
/// <param name="protoReader">
/// The proto reader.
/// </param>
/// <returns>
/// The <see cref="MxMessage"/>.
/// </returns>
private static MxMessage Read(MxMessage mxMessage, ProtoReader protoReader)
{
int num;
while ((num = protoReader.ReadFieldHeader()) > 0)
{
if (num != 1)
{
if (num != 2)
{
if (num != 3)
{
if (num != 4)
{
if (num != 6)
{
if (mxMessage == null)
{
var expr_170 = new MxMessage();
ProtoReader.NoteObject(expr_170, protoReader);
mxMessage = expr_170;
}
protoReader.SkipField();
}
else
{
if (mxMessage == null)
{
var expr_D9 = new MxMessage();
ProtoReader.NoteObject(expr_D9, protoReader);
mxMessage = expr_D9;
}
MxPayload[] payloads = mxMessage.Payloads;
var list = new List<MxPayload>();
int num2 = protoReader.FieldNumber;
do
{
List<MxPayload> arg_111_0 = list;
MxPayload arg_104_0 = null;
SubItemToken token = ProtoReader.StartSubItem(protoReader);
MxPayload arg_111_1 = Read(arg_104_0, protoReader);
ProtoReader.EndSubItem(token, protoReader);
arg_111_0.Add(arg_111_1);
}
while (protoReader.TryReadFieldHeader(num2));
MxPayload[] expr_124 = payloads;
var array =
new MxPayload[(num2 = (expr_124 != null) ? expr_124.Length : 0) + list.Count];
if (num2 != 0)
{
payloads.CopyTo(array, 0);
}
list.CopyTo(array, num2);
array = array;
if (array != null)
{
mxMessage.Payloads = array;
}
}
}
else
{
if (mxMessage == null)
{
var expr_A9 = new MxMessage();
ProtoReader.NoteObject(expr_A9, protoReader);
mxMessage = expr_A9;
}
uint num3 = protoReader.ReadUInt32();
mxMessage.AckBitfield = num3;
}
}
else
{
if (mxMessage == null)
{
var expr_79 = new MxMessage();
ProtoReader.NoteObject(expr_79, protoReader);
mxMessage = expr_79;
}
uint num3 = protoReader.ReadUInt32();
mxMessage.Ack = num3;
}
}
//.........这里部分代码省略.........