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


C# TypeDef.EffectiveName方法代码示例

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


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

示例1: AddTypeDef

        // ----------------------------------------------------------------------
        // Type definitions
        // ----------------------------------------------------------------------

        private void AddTypeDef(DllSaveContext ctxt, TypeDef typeDef)
        {

            var name = typeDef.EffectiveName(rootEnv.Global);

            //
            // Flags
            //
            var flags = default(PE.TypeAttributes);
            foreach (var annot in typeDef.Annotations)
            {
                var access = annot as AccessibilityAnnotation;
                if (access != null)
                {
                    switch (access.Accessibility)
                    {
                    case Accessibility.CompilerControlled:
                        break;
                    case Accessibility.Private:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedPrivate : PE.TypeAttributes.NotPublic;
                        break;
                    case Accessibility.FamilyANDAssembly:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedFamANDAssem : PE.TypeAttributes.NotPublic;
                        break;
                    case Accessibility.Assembly:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedAssembly : PE.TypeAttributes.NotPublic;
                        break;
                    case Accessibility.Family:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedFamily : PE.TypeAttributes.NotPublic;
                        break;
                    case Accessibility.FamilyORAssembly:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedFamORAssem : PE.TypeAttributes.NotPublic;
                        break;
                    case Accessibility.Public:
                        flags |= name.IsNested ? PE.TypeAttributes.NestedPublic : PE.TypeAttributes.Public;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                var layout = annot as TypeInteropAnnotation;
                if (layout != null)
                {
                    switch (layout.Layout)
                    {
                    case TypeLayout.Auto:
                        flags |= PE.TypeAttributes.AutoLayout;
                        break;
                    case TypeLayout.Sequential:
                        flags |= PE.TypeAttributes.SequentialLayout;
                        break;
                    case TypeLayout.Explicit:
                        flags |= PE.TypeAttributes.ExplicitLayout;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    switch (layout.StringFormat)
                    {
                    case StringFormat.Auto:
                        flags |= PE.TypeAttributes.AutoClass;
                        break;
                    case StringFormat.Ansi:
                        flags |= PE.TypeAttributes.AnsiClass;
                        break;
                    case StringFormat.Unicode:
                        flags |= PE.TypeAttributes.UnicodeClass;
                        break;
                    case StringFormat.Custom:
                        flags |= PE.TypeAttributes.CustomFormatClass;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    if (layout.IsSerializable)
                        flags |= PE.TypeAttributes.Serializable;
                }

                var security = annot as TypeSecurityAnnotation;
                if (security != null && security.HasSecurity)
                    flags |= PE.TypeAttributes.HasSecurity;

                var specialName = annot as SpecialNameAnnotation;
                if (specialName != null)
                {
                    flags |= PE.TypeAttributes.SpecialName;
                    if (specialName.IsRuntime)
                        flags |= PE.TypeAttributes.RTSpecialName;
                }
            }

            if (typeDef is InterfaceTypeDef)
                flags |= PE.TypeAttributes.Interface;
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:IL2JS,代码行数:101,代码来源:PESaver.cs


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