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


C# TypeRef.EnterConstructor方法代码示例

本文整理汇总了C#中TypeRef.EnterConstructor方法的典型用法代码示例。如果您正苦于以下问题:C# TypeRef.EnterConstructor方法的具体用法?C# TypeRef.EnterConstructor怎么用?C# TypeRef.EnterConstructor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeRef的用法示例。


在下文中一共展示了TypeRef.EnterConstructor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TypeSigFromTypeRef

        private PE.TypeSig TypeSigFromTypeRef(DllSaveContext ctxt, TypeRef typeRef)
        {
            if (typeRef.Equals(rootEnv.Global.TypedReferenceRef))
                return new PE.PrimitiveTypeSig { PrimitiveType = PE.PrimitiveType.TypedRef };
            else
            {
                var tyconEnv = typeRef.EnterConstructor(rootEnv);

                switch (tyconEnv.Type.Flavor)
                {
                    case TypeDefFlavor.Pointer:
                        {
                            var p = (PointerTypeDef)tyconEnv.Type;
                            switch (p.PointerFlavor)
                            {
                                case PointerFlavor.Unmanaged:
                                    return new PE.UnmanagedPointerTypeSig { ElementType = TypeWithCustomModsFromTypeRef(ctxt, typeRef.Arguments[0]) };
                                case PointerFlavor.Managed:
                                    return new PE.ManagedPointerTypeSig { ElementType = TypeSigFromTypeRef(ctxt, typeRef.Arguments[0]) };
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                        }
                    case TypeDefFlavor.CodePointer:
                        {
                            var p = (CodePointerTypeDef)tyconEnv.Type;
                            switch (p.CodePointerFlavor)
                            {
                                case CodePointerFlavor.Function:
                                    throw new NotImplementedException();
                                case CodePointerFlavor.Action:
                                    throw new NotImplementedException();
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                            break;
                        }
                    case TypeDefFlavor.Array:
                        return new PE.ArrayTypeSig { ElementType = TypeWithCustomModsFromTypeRef(ctxt, typeRef.Arguments[0]) };
                    case TypeDefFlavor.MultiDimArray:
                        {
                            var a = (MultiDimArrayTypeDef)tyconEnv.Type;
                            return new PE.MultiDimArrayTypeSig
                                   {
                                       ElementType = TypeSigFromTypeRef(ctxt, typeRef.Arguments[0]),
                                       Rank = a.Rank,
                                       LoBounds = a.Bounds.LoBounds(),
                                       Sizes = a.Bounds.Sizes()
                                   };
                        }
                    case TypeDefFlavor.Box:
                        throw new InvalidOperationException("unexpected box type");
                    case TypeDefFlavor.Null:
                        throw new InvalidOperationException("unexpected null type");
                    case TypeDefFlavor.Parameter:
                        {
                            var p = (ParameterTypeDef)tyconEnv.Type;
                            switch (p.ParameterFlavor)
                            {
                                case ParameterFlavor.Type:
                                    return new PE.TypeParameterTypeSig { Index = p.Index };
                                case ParameterFlavor.Method:
                                    return new PE.MethodParameterTypeSig { Index = p.Index };
                                default:
                                    throw new ArgumentOutOfRangeException();
                            }
                        }
                    case TypeDefFlavor.Handle:
                    case TypeDefFlavor.Nullable:
                    case TypeDefFlavor.Enum:
                    case TypeDefFlavor.Struct:
                        {
                            var applicand = new PE.TypeDefOrRefSig
                                            {
                                                IsValueType = true,
                                                TypeDefOrRef = { Value = TypeDefOrRefRowFromQualifiedTypeName(ctxt, typeRef.QualifiedTypeName) }
                                            };
                            if (typeRef.Arguments.Count > 0)
                                return new PE.ApplicationTypeSig
                                       {
                                           Applicand = applicand,
                                           Arguments = typeRef.Arguments.Select(t => TypeSigFromTypeRef(ctxt, t)).ToSeq()
                                       };
                            else
                                return applicand;
                        }
                    case TypeDefFlavor.Void:
                        return new PE.PrimitiveTypeSig { PrimitiveType = PE.PrimitiveType.Void };
                    case TypeDefFlavor.Number:
                        {
                            var n = (NumberTypeDef)tyconEnv.Type;
                            var p = default(PE.PrimitiveType);
                            switch (n.NumberFlavor)
                            {
                                case NumberFlavor.Int8:
                                    p = PE.PrimitiveType.Int8;
                                    break;
                                case NumberFlavor.Int16:
                                    p = PE.PrimitiveType.Int16;
                                    break;
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:IL2JS,代码行数:101,代码来源:PESaver.cs


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