本文整理汇总了C#中ObjectWriter.TouchAndWriteTypeId方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectWriter.TouchAndWriteTypeId方法的具体用法?C# ObjectWriter.TouchAndWriteTypeId怎么用?C# ObjectWriter.TouchAndWriteTypeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectWriter
的用法示例。
在下文中一共展示了ObjectWriter.TouchAndWriteTypeId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public void Write(ObjectWriter writer)
{
writer.TouchAndWriteTypeId(UnderlyingMethod.ReflectedType);
var methodParameters = UnderlyingMethod.GetParameters();
if(UnderlyingMethod.IsGenericMethod)
{
var genericDefinition = UnderlyingMethod.GetGenericMethodDefinition();
var genericArguments = UnderlyingMethod.GetGenericArguments();
var genericMethodParamters = genericDefinition.GetParameters();
writer.PrimitiveWriter.Write(genericDefinition.Name);
writer.PrimitiveWriter.Write(genericArguments.Length);
for(int i = 0; i < genericArguments.Length; i++)
{
writer.TouchAndWriteTypeId(genericArguments[i]);
}
writer.PrimitiveWriter.Write(genericMethodParamters.Length);
for(int i = 0; i < genericMethodParamters.Length; i++)
{
writer.PrimitiveWriter.Write(genericMethodParamters[i].ParameterType.IsGenericParameter);
if(genericMethodParamters[i].ParameterType.IsGenericParameter)
{
writer.PrimitiveWriter.Write(genericMethodParamters[i].ParameterType.GenericParameterPosition);
}
else
{
writer.TouchAndWriteTypeId(methodParameters[i].ParameterType);
}
}
}
else
{
writer.PrimitiveWriter.Write(UnderlyingMethod.Name);
writer.PrimitiveWriter.Write(0); // no generic arguments
writer.PrimitiveWriter.Write(methodParameters.Length);
foreach(var p in methodParameters)
{
writer.TouchAndWriteTypeId(p.ParameterType);
}
}
}
示例2: WriteStructureStamp
private void WriteStructureStamp(ObjectWriter writer)
{
if(baseType == null)
{
writer.PrimitiveWriter.Write(Consts.NullObjectId);
}
else
{
writer.TouchAndWriteTypeId(baseType.UnderlyingType);
}
writer.PrimitiveWriter.Write(fields.Count);
foreach(var field in fields)
{
field.WriteTo(writer);
}
}