📄 assembly.cs
字号:
{ ThrowLoadError(assemblyFile, error); return null; } }#if !ECMA_COMPAT // Load an assembly using evidence (which we dont' use in // this implemantation). public static Assembly Load(String assemblyString, Evidence assemblySecurity) { return Load(assemblyString, GetCallingAssembly()); } // Load an assembly given an assembly name. public static Assembly Load(AssemblyName assemblyRef) { if(assemblyRef == null) { throw new ArgumentNullException("assemblyRef"); } return Load(assemblyRef.FullName, GetCallingAssembly()); } public static Assembly Load(AssemblyName assemblyRef, Evidence assemblySecurity) { if(assemblyRef == null) { throw new ArgumentNullException("assemblyRef"); } return Load(assemblyRef.FullName, GetCallingAssembly()); } // Load an assembly from a raw byte image. public static Assembly Load(byte[] rawAssembly) { return AppDomain.CurrentDomain.Load (rawAssembly, null, null, GetCallingAssembly()); } public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore) { return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, null, GetCallingAssembly()); } public static Assembly Load(byte[] rawAssembly, byte[] rawSymbolStore, Evidence securityEvidence) { return AppDomain.CurrentDomain.Load (rawAssembly, rawSymbolStore, securityEvidence, GetCallingAssembly()); } // Load an assembly from a file. public static Assembly LoadFile(String path) { return LoadFrom(path, GetCallingAssembly()); } public static Assembly LoadFile(String path, Evidence securityEvidence) { return LoadFrom(path, GetCallingAssembly()); } public static Assembly LoadFrom(String assemblyFile, Evidence securityEvidence) { return LoadFrom(assemblyFile, GetCallingAssembly()); } public static Assembly LoadFrom(String assemblyFile, Evidence securityEvidence, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) { return LoadFrom(assemblyFile, GetCallingAssembly()); } // Load an assembly using a partial name. public static Assembly LoadWithPartialName(String partialName) { return LoadWithPartialName(partialName, GetCallingAssembly()); } public static Assembly LoadWithPartialName(String partialName, Evidence securityEvidence) { return LoadWithPartialName(partialName, GetCallingAssembly()); } private static Assembly LoadWithPartialName(String partialName, Assembly caller) { Assembly assembly; AssemblyName name; int error; if(partialName == null) { throw new ArgumentNullException("partialName"); } name = AssemblyName.Parse(partialName); assembly = LoadFromName(name.Name, out error, caller); if(error == LoadError_OK) { return assembly; } else { return null; } }#endif // !ECMA_COMPAT // Convert this assembly into a string. public override String ToString() { String name = FullName; if(name != null) { return name; } else { return base.ToString(); } } // Get the full name associated with this assembly. [MethodImpl(MethodImplOptions.InternalCall)] extern private String GetFullName(); // Get the full name associated with this assembly. public virtual String FullName { get { return GetFullName(); } }#if !ECMA_COMPAT // Get the code base associated with this assembly. public virtual String CodeBase { get { return GetName().CodeBase; } } // Get the escaped code base associated with this assembly. public virtual String EscapedCodeBase { get { return GetName().EscapedCodeBase; } } // Get the entry point for this assembly. public virtual MethodInfo EntryPoint { get { return (MethodInfo)(MethodBase.GetMethodFromHandle (GetEntryPoint())); } } // Get the security evidence for this assembly. public virtual Evidence Evidence { get { // We don't use evidence objects in this implementation // at the moment, so return a dummy evidence object. return new Evidence(); } } // Determine if this assembly was loaded from the global assembly cache. public bool GlobalAssemblyCache { get { // We don't use a GAC in this implementation, or if // we do then we leave it up to the engine to decide. return false; } } // Get the runtime version that the assembly was compiled against. [ComVisible(false)] public virtual String ImageRuntimeVersion { get { return GetImageRuntimeVersion(); } } [MethodImpl(MethodImplOptions.InternalCall)] extern private String GetImageRuntimeVersion(); // Get the location where this assembly was loaded from. public virtual String Location { get { String retval; retval = GetLocation(); return (retval == null) ? "" : retval; } } [MethodImpl(MethodImplOptions.InternalCall)] extern private String GetLocation(); // Get the assembly that a particular type resides in. public static Assembly GetAssembly(Type type) { if(type == null) { throw new ArgumentNullException("type"); } return type.Assembly; } // Get the entry point method for this assembly. [MethodImpl(MethodImplOptions.InternalCall)] extern private RuntimeMethodHandle GetEntryPoint();#endif // !ECMA_COMPAT // Get the full pathname of a satellite file underneath // the directory containing this assembly. Returns null // if it isn't possible to retrieve the path or the file // doesn't exist. [MethodImpl(MethodImplOptions.InternalCall)] extern internal String GetSatellitePath(String filename);#if CONFIG_REFLECTION && !ECMA_COMPAT // Module resolution event. public event ModuleResolveEventHandler ModuleResolve;#if CONFIG_SERIALIZATION // Serialize this object. public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if(info == null) { throw new ArgumentNullException("info"); } UnitySerializationHolder.Serialize (info, UnitySerializationHolder.UnityType.Assembly, FullName, this); }#endif // CONFIG_SERIALIZATION // Get the loaded modules within this assembly. We make no // distinction between loaded and unloaded in this implementation, // because the runtime engine hides the loading of modules. public Module[] GetLoadedModules() { return GetModules(false); } public Module[] GetLoadedModules(bool getResourceModules) { return GetModules(getResourceModules); } // Get a module by name from this assembly. [MethodImpl(MethodImplOptions.InternalCall)] extern private Module GetModuleInternal(String name); // Get a particular module from within this assembly. public Module GetModule(String name) { if(name == null) { throw new ArgumentNullException("name"); } else if(name.Length == 0) { throw new ArgumentException (_("ArgRange_StringNonEmpty"), "name"); } return GetModuleInternal(name); } // Get the modules within this assembly. public Module[] GetModules() { return GetModules(false); } [MethodImpl(MethodImplOptions.InternalCall)] extern public Module[] GetModules(bool getResourceModules); // Fill in an assembly name block with a loaded assembly's information. [MethodImpl(MethodImplOptions.InternalCall)] extern private void FillAssemblyName(AssemblyName nameInfo); // Get the name of this assembly. public virtual AssemblyName GetName() { AssemblyName nameInfo = new AssemblyName(); String filename = GetLocation(); if(filename != null && filename.Length > 0) { if(filename[0] == '/' || filename[0] == '\\') { nameInfo.CodeBase = "file://" + filename.Replace('\\', '/'); } else { nameInfo.CodeBase = "file:///" + filename.Replace('\\', '/'); } } FillAssemblyName(nameInfo); return nameInfo; } public virtual AssemblyName GetName(bool copiedName) { // We don't support shadow copies in this implementation. return GetName(); } // Get the assemblies referenced by this one. [MethodImpl(MethodImplOptions.InternalCall)] extern private Assembly[] GetReferencedAssembliesInternal(); // Get a list of the assemblies that are referenced by this one. public AssemblyName[] GetReferencedAssemblies() { Assembly[] list = GetReferencedAssembliesInternal(); if(list == null) { return null; } AssemblyName[] names = new AssemblyName [list.Length]; int posn; for(posn = 0; posn < list.Length; ++posn) { names[posn] = list[posn].GetName(); } return names; } // Get a satellite resource assembly. public Assembly GetSatelliteAssembly(CultureInfo culture) { return GetSatelliteAssembly (culture, null, GetCallingAssembly()); } public Assembly GetSatelliteAssembly(CultureInfo culture, Version version) { return GetSatelliteAssembly (culture, version, GetCallingAssembly()); } private Assembly GetSatelliteAssembly(CultureInfo culture, Version version, Assembly caller) { if(culture == null) { throw new ArgumentNullException("culture"); } String baseName = culture.Name + Path.DirectorySeparatorChar + FullName + ".resources.dll"; String path = GetSatellitePath(baseName); if(path == null) { throw new FileNotFoundException (String.Format (_("Reflection_AssemblyFile"), baseName)); } else { return LoadFrom(path, caller); } } // Load a raw module and attach it to this assembly. public Module LoadModule(String moduleName, byte[] rawModule) { return LoadModule(moduleName, rawModule, null); } public Module LoadModule(String moduleName, byte[] rawModule, byte[] rawSymbolStore) { // Raw module loading is not supported in this implementation. // It is too dangerous security-wise. throw new SecurityException (String.Format (_("Reflection_AssemblySecurity"), moduleName)); }#endif // CONFIG_REFLECTION && !ECMA_COMPAT}; // class Assembly#endif // CONFIG_RUNTIME_INFRA}; // namespace System.Reflection
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -