本文整理汇总了C#中ProtoReader.AppendExtensionData方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoReader.AppendExtensionData方法的具体用法?C# ProtoReader.AppendExtensionData怎么用?C# ProtoReader.AppendExtensionData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoReader
的用法示例。
在下文中一共展示了ProtoReader.AppendExtensionData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public object Read(object value, ProtoReader source)
{
if (isRootType && value != null) { Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context); }
int fieldNumber, lastFieldNumber = 0, lastFieldIndex = 0;
bool fieldHandled;
//Helpers.DebugWriteLine(">> Reading fields for " + forType.FullName);
while ((fieldNumber = source.ReadFieldHeader()) > 0)
{
fieldHandled = false;
if (fieldNumber < lastFieldNumber)
{
lastFieldNumber = lastFieldIndex = 0;
}
for (int i = lastFieldIndex; i < fieldNumbers.Length; i++)
{
if (fieldNumbers[i] == fieldNumber)
{
IProtoSerializer ser = serializers[i];
//Helpers.DebugWriteLine(": " + ser.ToString());
if (value == null && ser.ExpectedType == forType) value = CreateInstance(source);
if (ser.ReturnsValue) {
value = ser.Read(value, source);
} else { // pop
ser.Read(value, source);
}
lastFieldIndex = i;
lastFieldNumber = fieldNumber;
fieldHandled = true;
break;
}
}
if (!fieldHandled)
{
//Helpers.DebugWriteLine(": [" + fieldNumber + "] (unknown)");
if (value == null) value = CreateInstance(source);
if (isExtensible) {
source.AppendExtensionData((IExtensible)value);
} else {
source.SkipField();
}
}
}
//Helpers.DebugWriteLine("<< Reading fields for " + forType.FullName);
if(value == null) value = CreateInstance(source);
if (isRootType) { Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context); }
return value;
}
示例2: Read
public object Read(object value, ProtoReader source)
{
if (this.isRootType && value != null)
{
this.Callback(value, TypeModel.CallbackType.BeforeDeserialize, source.Context);
}
int num = 0;
int num2 = 0;
int num3;
while ((num3 = source.ReadFieldHeader()) > 0)
{
bool flag = false;
if (num3 < num)
{
num2 = (num = 0);
}
for (int i = num2; i < this.fieldNumbers.Length; i++)
{
if (this.fieldNumbers[i] == num3)
{
IProtoSerializer protoSerializer = this.serializers[i];
Type expectedType = protoSerializer.ExpectedType;
if (value == null)
{
if (expectedType == this.forType)
{
value = this.CreateInstance(source, true);
}
}
else if (expectedType != this.forType && ((IProtoTypeSerializer)protoSerializer).CanCreateInstance() && expectedType.IsSubclassOf(value.GetType()))
{
value = ProtoReader.Merge(source, value, ((IProtoTypeSerializer)protoSerializer).CreateInstance(source));
}
if (protoSerializer.ReturnsValue)
{
value = protoSerializer.Read(value, source);
}
else
{
protoSerializer.Read(value, source);
}
num2 = i;
num = num3;
flag = true;
break;
}
}
if (!flag)
{
if (value == null)
{
value = this.CreateInstance(source, true);
}
if (this.isExtensible)
{
source.AppendExtensionData((IExtensible)value);
}
else
{
source.SkipField();
}
}
}
if (value == null)
{
value = this.CreateInstance(source, true);
}
if (this.isRootType)
{
this.Callback(value, TypeModel.CallbackType.AfterDeserialize, source.Context);
}
return value;
}