コード例 #1
0
        public static AssemblyNameReference GetAssemblyNameReference(this IMetadataScope scope)
        {
            MetadataScopeType metadataScopeType = scope.MetadataScopeType;

            if (metadataScopeType != MetadataScopeType.AssemblyNameReference)
            {
                if (metadataScopeType != MetadataScopeType.ModuleDefinition)
                {
                    throw new NotSupportedException(string.Format("Metadata scope type {0} is not supported.", scope.MetadataScopeType));
                }
                return(((ModuleDefinition)scope).Assembly.Name);
            }
            return((AssemblyNameReference)scope);
        }
コード例 #2
0
        private static string GetScopeFullName(TypeReference type)
        {
            IMetadataScope    scope             = type.Scope;
            MetadataScopeType metadataScopeType = scope.MetadataScopeType;

            if (metadataScopeType == MetadataScopeType.AssemblyNameReference)
            {
                return(((AssemblyNameReference)scope).FullName);
            }
            if (metadataScopeType != MetadataScopeType.ModuleDefinition)
            {
                throw new ArgumentException();
            }
            return(((ModuleDefinition)scope).Assembly.Name.FullName);
        }