示例#1
0
            public XElement ToXml()
            {
                var element = new XElement(GetTypeName());

                if (scope != null)
                {
                    element.Add(new XAttribute("scope", scope.ToString()));
                }
                element.Add(new XText(member));
                return(element);
            }
示例#2
0
        private static string GetAssemblyName([CanBeNull] IMetadataScope scope)
        {
            if (scope == null)
            {
                return(null);
            }

            if (scope is ModuleDefinition md)
            {
                return(md.Assembly.FullName);
            }

            return(scope.ToString());
        }
示例#3
0
文件: AccCIL.cs 项目: PlumpMath/ac3il
        public static string FindAssemblyName(MethodReference mr)
        {
            IMetadataScope scope = mr.DeclaringType.Scope;

            if (scope is ModuleDefinition)
            {
                scope = (AssemblyNameReference)((ModuleDefinition)scope).Assembly.Name;
            }

            if (scope is AssemblyNameReference)
            {
                return(scope.ToString());
            }
            else
            {
                throw new Exception("Unexpected scope token: " + scope);
            }
        }
示例#4
0
        public static string getCanonicalizedScopeName(IMetadataScope scope)
        {
            AssemblyNameReference asmRef = null;

            switch (scope.MetadataScopeType) {
            case MetadataScopeType.AssemblyNameReference:
                asmRef = (AssemblyNameReference)scope;
                break;
            case MetadataScopeType.ModuleDefinition:
                var module = (ModuleDefinition)scope;
                if (module.Assembly != null)
                    asmRef = module.Assembly.Name;
                break;
            case MetadataScopeType.ModuleReference:
                break;
            default:
                throw new ApplicationException(string.Format("Invalid scope type: {0}", scope.GetType()));
            }

            if (asmRef != null) {
                // The version number should be ignored. Older code may reference an old version of
                // the assembly, but if the newer one has been loaded, that one is used.
                return asmRef.Name.ToLowerInvariant();
            }
            return string.Format("{0}", scope.ToString().ToLowerInvariant());
        }