当前位置: 首页>>代码示例>>C#>>正文


C# ObjectWriter.TouchAndWriteTypeId方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:44,代码来源:MethodDescriptor.cs

示例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);
            }
        }
开发者ID:StepWoodProductions,项目名称:Migrant,代码行数:17,代码来源:TypeFullDescriptor.cs


注:本文中的ObjectWriter.TouchAndWriteTypeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。