• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Reflection.Assembly类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IKVM.Reflection.Assembly的典型用法代码示例。如果您正苦于以下问题:C# Assembly类的具体用法?C# Assembly怎么用?C# Assembly使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Assembly类属于IKVM.Reflection命名空间,在下文中一共展示了Assembly类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Init

        public static void Init(string baseCorlibDir)
        {
            if (baseCorlibDir == null)
                baseCorlibDir = typeof(int).Assembly.Location;
            mscorlib = universe.LoadFile(baseCorlibDir);
            if (mscorlib == null)
            {
                Report.Error($"Could not load mscorlib from {baseCorlibDir}");
            }
            AttributeType = mscorlib.GetType("System.Attribute");
            VoidType = mscorlib.GetType("System.Void");
            IntPtrType = mscorlib.GetType("System.IntPtr");
            UIntPtrType = mscorlib.GetType("System.UIntPtr");
            StringType = mscorlib.GetType("System.String");
            ObjectType = mscorlib.GetType("System.Object");
            TypeType = mscorlib.GetType("System.Type");

            MethodInfoType = mscorlib.GetType("System.Reflection.MethodInfo");
            FieldInfoType = mscorlib.GetType("System.Reflection.FieldInfo");
            PropertyInfoType = mscorlib.GetType("System.Reflection.PropertyInfo");
            AssemblyType = mscorlib.GetType("System.Reflection.Assembly");
            ModuleType = mscorlib.GetType("System.Reflection.Module");
        }
开发者ID:robert-j,项目名称:Mono.Embedding,代码行数:23,代码来源:Program.cs


示例2: __GetDeclarativeSecurity

		public static IList<CustomAttributeData> __GetDeclarativeSecurity(Assembly assembly)
		{
			return assembly.ManifestModule.GetDeclarativeSecurity(0x20000001);
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:4,代码来源:CustomAttributeData.cs


示例3: MissingModule

		internal MissingModule(Assembly assembly, int index)
			: base(assembly.universe)
		{
			this.assembly = assembly;
			this.index = index;
		}
开发者ID:Semogj,项目名称:ikvm-fork,代码行数:6,代码来源:Missing.cs


示例4: IsSigned

		private static bool IsSigned(Assembly asm)
		{
			byte[] key = asm.GetName().GetPublicKey();
			return key != null && key.Length != 0;
		}
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:5,代码来源:CompilerClassLoader.cs


示例5: __ResolveReferencedAssemblies

		public virtual void __ResolveReferencedAssemblies(Assembly[] assemblies)
		{
			throw new NotSupportedException();
		}
开发者ID:nestalk,项目名称:mono,代码行数:4,代码来源:Module.cs


示例6: __GetCustomAttributes

		public static IList<CustomAttributeData> __GetCustomAttributes(Assembly assembly, Type attributeType, bool inherit)
		{
			return assembly.GetCustomAttributesData(attributeType);
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:4,代码来源:CustomAttributeData.cs


示例7: CustomAttributeData

		// 5) Unresolved declarative security
		internal CustomAttributeData(Assembly asm, ConstructorInfo constructor, int securityAction, byte[] blob, int index)
		{
			this.module = asm.ManifestModule;
			this.customAttributeIndex = -1;
			this.declSecurityIndex = index;
			Universe u = constructor.Module.universe;
			this.lazyConstructor = constructor;
			List<CustomAttributeTypedArgument> list = new List<CustomAttributeTypedArgument>();
			list.Add(new CustomAttributeTypedArgument(u.System_Security_Permissions_SecurityAction, securityAction));
			this.lazyConstructorArguments =  list.AsReadOnly();
			this.declSecurityBlob = blob;
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:13,代码来源:CustomAttributeData.cs


示例8: RenameAssembly

		internal void RenameAssembly(Assembly assembly, AssemblyName oldName)
		{
			List<string> remove = new List<string>();
			foreach (KeyValuePair<string, Assembly> kv in assembliesByName)
			{
				if (kv.Value == assembly)
				{
					remove.Add(kv.Key);
				}
			}
			foreach (string key in remove)
			{
				assembliesByName.Remove(key);
			}
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:15,代码来源:Universe.cs


示例9: GetType

		// note that context is slightly different from the calling assembly (System.Type.GetType),
		// because context is passed to the AssemblyResolve event as the RequestingAssembly
		public Type GetType(Assembly context, string assemblyQualifiedTypeName, bool throwOnError)
		{
			TypeNameParser parser = TypeNameParser.Parse(assemblyQualifiedTypeName, throwOnError);
			if (parser.Error)
			{
				return null;
			}
			return parser.GetType(this, context, throwOnError, assemblyQualifiedTypeName);
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:11,代码来源:Universe.cs


示例10: Load

		internal Assembly Load(string refname, Assembly requestingAssembly, bool throwOnError)
		{
			Assembly asm = GetLoadedAssembly(refname);
			if (asm != null)
			{
				return asm;
			}
			if (resolvers.Count == 0)
			{
				asm = DefaultResolver(refname, throwOnError);
			}
			else
			{
				ResolveEventArgs args = new ResolveEventArgs(refname, requestingAssembly);
				foreach (ResolveEventHandler evt in resolvers)
				{
					asm = evt(this, args);
					if (asm != null)
					{
						break;
					}
				}
			}
			if (asm != null)
			{
				string defname = asm.FullName;
				if (refname != defname)
				{
					assembliesByName.Add(refname, asm);
				}
				return asm;
			}
			if (throwOnError)
			{
				throw new FileNotFoundException(refname);
			}
			return null;
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:38,代码来源:Universe.cs


示例11: ResolveEventArgs

		public ResolveEventArgs(string name, Assembly requestingAssembly)
		{
			this.name = name;
			this.requestingAssembly = requestingAssembly;
		}
开发者ID:ikvm,项目名称:IKVM.NET-cvs-clone,代码行数:5,代码来源:Universe.cs


示例12: Process

        static void Process(Assembly asm)
        {
            currentAssembly = asm;
            string shortName = asm.GetName().Name;
            string name = shortName.Replace(".", "_");

            var typeList = new List<IKVM.Reflection.Type>();

            headerWriter.WriteLine("/*");
            headerWriter.WriteLine(" * Automatically generated by thunktool from {0}", shortName);
            headerWriter.WriteLine(" */");
            headerWriter.WriteLine();
            headerWriter.WriteLine("#ifndef __{0}_THUNKTOOL__", name.ToUpperInvariant());
            headerWriter.WriteLine("#define __{0}_THUNKTOOL__", name.ToUpperInvariant());
            headerWriter.WriteLine();
            headerWriter.WriteLine("#include <mono/utils/mono-publib.h>");
            headerWriter.WriteLine("#include <mono/metadata/assembly.h>");
            headerWriter.WriteLine("#include <mono/metadata/class.h>");
            headerWriter.WriteLine("#include <mono/metadata/object.h>");
            headerWriter.WriteLine();
            headerWriter.WriteLine("MONO_BEGIN_DECLS");
            headerWriter.WriteLine();
            headerWriter.WriteLine("#ifdef WIN32");
            headerWriter.WriteLine("#define THUNKCALL __stdcall");
            headerWriter.WriteLine("#else");
            headerWriter.WriteLine("#define THUNKCALL");
            headerWriter.WriteLine("#endif");
            headerWriter.WriteLine();

            sourceWriter.WriteLine("/*");
            sourceWriter.WriteLine(" * Automatically generated by thunktool from {0}", shortName);
            sourceWriter.WriteLine(" */");
            sourceWriter.WriteLine();
            sourceWriter.WriteLine("#include <stdlib.h>");
            sourceWriter.WriteLine("#include <string.h>");
            sourceWriter.WriteLine("#include <assert.h>");
            sourceWriter.WriteLine("#include <mono/jit/jit.h>");
            sourceWriter.WriteLine("#include <mono/metadata/reflection.h>");
            sourceWriter.WriteLine("#include \"{0}.h\"", outputPrefix ?? "thunks");
            sourceWriter.WriteLine();

            foreach (var typeInfo in asm.GetTypes ())
            {
                currentMethods = new List<ThunkMethodInfo>();

                foreach (var ctor in typeInfo.GetConstructors ())
                    Process(ctor);

                foreach (var method in typeInfo.GetMethods ())
                    Process(method);

                foreach (var prop in typeInfo.GetProperties ())
                    Process(prop);

                if (currentMethods.Count == 0)
                   continue;

                headerWriter.WriteLine("MonoClass *{0}__Class;", typeInfo.Name);

                foreach (var m in currentMethods) {
                    headerWriter.WriteLine();

                    if (wantComments)
                        headerWriter.WriteLine("/*\n * {0}\n */", m.Comments);

                    if (!m.IsGeneric)
                        headerWriter.WriteLine("{0}", m.QualMethodDecl);
                    else
                        headerWriter.WriteLine("MonoMethod *{0}__Method;", m.QualMethodName);
                }

                headerWriter.WriteLine();

                sourceWriter.WriteLine("static void\n{0}_Init (MonoClass *klass)", typeInfo.Name);
                sourceWriter.WriteLine("{");
                sourceWriter.WriteLine("\tMonoMethod *method;\n");
                sourceWriter.WriteLine("\tassert (klass && \"could not lookup class '{0}'\");", typeInfo.FullName);
                sourceWriter.WriteLine("\t{0}__Class = klass;", typeInfo.Name);
                foreach (var m in currentMethods)
                {
                    sourceWriter.WriteLine();
                    sourceWriter.WriteLine("\tmethod = mono_class_get_method_from_name (klass, \"{0}\", -1);", m.ClrMethodName);
                    sourceWriter.WriteLine("\tassert (method && \"could not lookup method '{0}.{1}'\");", typeInfo.FullName, m.ClrMethodName);
                    if (!m.IsGeneric)
                        sourceWriter.WriteLine("\t{0} = mono_method_get_unmanaged_thunk (method);", m.QualMethodName);
                    else
                        sourceWriter.WriteLine("\t{0}__Method = method;", m.QualMethodName);
                }
                sourceWriter.WriteLine("}\n");

                typeList.Add(typeInfo);
            }

            if (typeList.Count > 0)
            {
                headerWriter.WriteLine("MonoAssembly *{0}_Assembly;", name);
                headerWriter.WriteLine("MonoImage *{0}_Image;", name);
                headerWriter.WriteLine();
                headerWriter.WriteLine("void\n{0}_Init (MonoAssembly *assembly);", name);
                headerWriter.WriteLine();
//.........这里部分代码省略.........
开发者ID:robert-j,项目名称:Mono.Embedding,代码行数:101,代码来源:Program.cs


示例13: ReadDeclarativeSecurity

		internal static void ReadDeclarativeSecurity(Assembly asm, List<CustomAttributeData> list, int action, ByteReader br)
		{
			Universe u = asm.universe;
			if (br.PeekByte() == '.')
			{
				br.ReadByte();
				int count = br.ReadCompressedInt();
				for (int j = 0; j < count; j++)
				{
					Type type = ReadType(asm, br);
					ConstructorInfo constructor = type.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
					// LAMESPEC there is an additional length here (probably of the named argument list)
					byte[] blob = br.ReadBytes(br.ReadCompressedInt());
					list.Add(new CustomAttributeData(asm, constructor, action, blob));
				}
			}
			else
			{
				// .NET 1.x format (xml)
				char[] buf = new char[br.Length / 2];
				for (int i = 0; i < buf.Length; i++)
				{
					buf[i] = br.ReadChar();
				}
				string xml = new String(buf);
				ConstructorInfo constructor = u.System_Security_Permissions_PermissionSetAttribute.GetPseudoCustomAttributeConstructor(u.System_Security_Permissions_SecurityAction);
				List<CustomAttributeNamedArgument> args = new List<CustomAttributeNamedArgument>();
				args.Add(new CustomAttributeNamedArgument(GetProperty(u.System_Security_Permissions_PermissionSetAttribute, "XML", u.System_String),
					new CustomAttributeTypedArgument(u.System_String, xml)));
				list.Add(new CustomAttributeData(asm.ManifestModule, constructor, new object[] { action }, args));
			}
		}
开发者ID:kazol4433,项目名称:mono,代码行数:32,代码来源:CustomAttributeData.cs


示例14: GetAssemblyReference

 IAssemblyReference GetAssemblyReference(Assembly scope)
 {
     if (scope == null || scope == currentAssemblyDefinition)
         return DefaultAssemblyReference.CurrentAssembly;
     return interningProvider.Intern (new DefaultAssemblyReference (scope.FullName));
 }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:6,代码来源:IkvmLoader.cs


示例15: AssemblyLocationProvider

			public AssemblyLocationProvider (Assembly assembly, MonoSymbolFile symbolFile, string seqPointDataPath)
			{
				this.assembly = assembly;
				this.symbolFile = symbolFile;
				this.seqPointDataPath = seqPointDataPath;
			}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:6,代码来源:LocationProvider.cs


示例16: LoadAssembly

        public IUnresolvedAssembly LoadAssembly(Assembly assembly)
        {
            if (assembly == null)
                throw new ArgumentNullException ("assembly");

            // Read assembly and module attributes
            IList<IUnresolvedAttribute> assemblyAttributes = new List<IUnresolvedAttribute>();
            IList<IUnresolvedAttribute> moduleAttributes = new List<IUnresolvedAttribute>();
            AddAttributes(assembly, assemblyAttributes);
            AddAttributes(assembly.ManifestModule, moduleAttributes);

            assemblyAttributes = interningProvider.InternList(assemblyAttributes);
            moduleAttributes = interningProvider.InternList(moduleAttributes);

            currentAssemblyDefinition = assembly;
            currentAssembly = new IkvmUnresolvedAssembly (assembly.FullName, DocumentationProvider);
            currentAssembly.Location = assembly.Location;
            currentAssembly.AssemblyAttributes.AddRange(assemblyAttributes);
            currentAssembly.ModuleAttributes.AddRange(moduleAttributes);
            // Register type forwarders:
            foreach (var type in assembly.ManifestModule.__GetExportedTypes ()) {
                if (type.Assembly != assembly) {
                    int typeParameterCount;
                    string ns = type.Namespace;
                    string name = ReflectionHelper.SplitTypeParameterCountFromReflectionName(type.Name, out typeParameterCount);
                    ns = interningProvider.Intern(ns);
                    name = interningProvider.Intern(name);
                    var typeRef = new GetClassTypeReference(GetAssemblyReference(type.Assembly), ns, name, typeParameterCount);
                    typeRef = interningProvider.Intern(typeRef);
                    var key = new TopLevelTypeName(ns, name, typeParameterCount);
                    currentAssembly.AddTypeForwarder(key, typeRef);
                }
            }

            // Create and register all types:
            var ikvmTypeDefs = new List<IKVM.Reflection.Type>();
            var typeDefs = new List<DefaultUnresolvedTypeDefinition>();

            foreach (var td in assembly.GetTypes ()) {
                if (td.DeclaringType != null)
                    continue;
                CancellationToken.ThrowIfCancellationRequested();

                if (IncludeInternalMembers || td.IsPublic) {
                    string name = td.Name;
                    if (name.Length == 0)
                        continue;

                    var t = CreateTopLevelTypeDefinition(td);
                    ikvmTypeDefs.Add(td);
                    typeDefs.Add(t);
                    currentAssembly.AddTypeDefinition(t);
                    // The registration will happen after the members are initialized
                }
            }

            // Initialize the type's members:
            for (int i = 0; i < typeDefs.Count; i++) {
                InitTypeDefinition(ikvmTypeDefs[i], typeDefs[i]);
            }

            // Freezing the assembly here is important:
            // otherwise it will be frozen when a compilation is first created
            // from it. But freezing has the effect of changing some collection instances
            // (to ReadOnlyCollection). This hidden mutation was causing a crash
            // when the FastSerializer was saving the assembly at the same time as
            // the first compilation was created from it.
            // By freezing the assembly now, we ensure it is usable on multiple
            // threads without issues.
            currentAssembly.Freeze();

            var result = currentAssembly;
            currentAssembly = null;
            return result;
        }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:75,代码来源:IkvmLoader.cs


示例17: GetCustomAttributes

		public static IList<CustomAttributeData> GetCustomAttributes(Assembly assembly)
		{
			return assembly.GetCustomAttributesData(null);
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:4,代码来源:CustomAttributeData.cs


示例18: AddAttributes

        void AddAttributes(Assembly assembly, IList<IUnresolvedAttribute> outputList)
        {
            AddCustomAttributes(assembly.CustomAttributes, outputList);
            AddSecurityAttributes(CustomAttributeData.__GetDeclarativeSecurity (assembly), outputList);

            // AssemblyVersionAttribute
            if (assembly.GetName ().Version != null) {
                var assemblyVersion = new DefaultUnresolvedAttribute(assemblyVersionAttributeTypeRef, new[] { KnownTypeReference.String });
                assemblyVersion.PositionalArguments.Add(CreateSimpleConstantValue(KnownTypeReference.String, assembly.GetName ().Version.ToString()));
                outputList.Add(interningProvider.Intern(assemblyVersion));
            }
        }
开发者ID:jlyonsmith,项目名称:NRefactory,代码行数:12,代码来源:IkvmLoader.cs


示例19: __GetDeclarativeSecurity

		public static IList<CustomAttributeData> __GetDeclarativeSecurity(Assembly assembly)
		{
			if (assembly.__IsMissing)
			{
				throw new MissingAssemblyException((MissingAssembly)assembly);
			}
			return assembly.ManifestModule.GetDeclarativeSecurity(0x20000001);
		}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:8,代码来源:CustomAttributeData.cs


示例20: ToModule

		internal Module ToModule(Assembly assembly)
		{
			if (module.Assembly != null)
			{
				throw new InvalidOperationException();
			}
			imported = true;
			module.SetAssembly(assembly);
			return module;
		}
开发者ID:nestalk,项目名称:mono,代码行数:10,代码来源:Module.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Reflection.Module类代码示例发布时间:2022-05-26
下一篇:
C# MapXml.CodeGenContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap