本文整理汇总了C#中ObjectReader.ReadType方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectReader.ReadType方法的具体用法?C# ObjectReader.ReadType怎么用?C# ObjectReader.ReadType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectReader
的用法示例。
在下文中一共展示了ObjectReader.ReadType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadStructureStamp
private void ReadStructureStamp(ObjectReader reader, VersionToleranceLevel versionToleranceLevel)
{
baseType = (TypeFullDescriptor)reader.ReadType();
var noOfFields = reader.PrimitiveReader.ReadInt32();
for(int i = 0; i < noOfFields; i++)
{
var fieldDescriptor = new FieldDescriptor(this);
fieldDescriptor.ReadFrom(reader);
fields.Add(fieldDescriptor);
}
FieldsToDeserialize = VerifyStructure(versionToleranceLevel);
// TODO: do we need this line?
fullCache[UnderlyingType] = this;
}
示例2: Read
public void Read(ObjectReader reader)
{
var type = reader.ReadType().UnderlyingType;
var methodName = reader.PrimitiveReader.ReadString();
var genericArgumentsCount = reader.PrimitiveReader.ReadInt32();
var genericArguments = new Type[genericArgumentsCount];
for(int i = 0; i < genericArgumentsCount; i++)
{
genericArguments[i] = reader.ReadType().UnderlyingType;
}
var parametersCount = reader.PrimitiveReader.ReadInt32();
if(genericArgumentsCount > 0)
{
var parameters = new TypeOrGenericTypeArgument[parametersCount];
for(int i = 0; i < parameters.Length; i++)
{
var genericType = reader.PrimitiveReader.ReadBoolean();
parameters[i] = genericType ?
new TypeOrGenericTypeArgument(reader.PrimitiveReader.ReadInt32()) :
new TypeOrGenericTypeArgument(reader.ReadType().UnderlyingType);
}
UnderlyingMethod = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SingleOrDefault(m =>
m.IsGenericMethod &&
m.GetGenericMethodDefinition().Name == methodName &&
m.GetGenericArguments().Length == genericArgumentsCount &&
CompareGenericArguments(m.GetGenericMethodDefinition().GetParameters(), parameters));
if(UnderlyingMethod != null)
{
UnderlyingMethod = UnderlyingMethod.MakeGenericMethod(genericArguments);
}
}
else
{
var types = new Type[parametersCount];
for(int i = 0; i < types.Length; i++)
{
types[i] = reader.ReadType().UnderlyingType;
}
UnderlyingMethod = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, types, null);
}
}