We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
-
Expand
Microsoft.Win32
-
Expand
Microsoft.Win32.SafeHandles
-
Expand
System
-
Expand
System.Runtime.Hosting
-
Expand
System.Runtime.InteropServices
-
Expand
System.Runtime.CompilerServices
-
Expand
System.Collections
-
Expand
System.Collections.Generic
-
Expand
System.Collections.ObjectModel
-
Expand
System.Configuration.Assemblies
-
Expand
System.Diagnostics
-
Expand
System.Diagnostics.CodeAnalysis
-
Expand
System.Diagnostics.SymbolStore
-
Expand
System.Globalization
-
Expand
System.IO
-
Expand
System.IO.IsolatedStorage
-
Expand
System.Reflection
-
Expand
System.Reflection.Cache
-
Expand
System.Reflection.Emit
-
Expand
__ExceptionInfo
-
Expand
__ExceptionInstance
-
Expand
__FixupData
-
Expand
AssemblyBuilder
-
Expand
AssemblyBuilderAccess
-
Expand
AssemblyBuilderData
-
Expand
ConstructorBuilder
-
Expand
ConstructorOnTypeBuilderInstantiation
-
Expand
CustAttr
-
Expand
CustomAttributeBuilder
-
Expand
DestroyScout
-
Expand
DynamicILGenerator
-
Expand
DynamicILInfo
-
Expand
DynamicMethod
-
Expand
DynamicResolver
-
Expand
DynamicScope
-
Expand
EmptyCAHolder
-
Expand
Entry
-
Expand
EnumBuilder
-
Expand
EventBuilder
-
Expand
EventToken
-
Expand
FieldBuilder
-
Expand
FieldOnTypeBuilderInstantiation
-
Expand
FieldToken
-
Expand
FlowControl
-
Expand
Format
-
Expand
GenericMethodInfo
-
Expand
GenericTypeParameterBuilder
-
Expand
ILGenerator
-
Expand
Label
-
Expand
LineNumberInfo
-
Expand
LocalBuilder
-
Expand
LocalSymInfo
-
Expand
MethodBuilder
-
Expand
MethodBuilderInstantiation
-
Expand
MethodOnTypeBuilderInstantiation
-
Expand
MethodRental
-
Expand
MethodToken
-
Expand
ModuleBuilder
-
CheckContext(Type)
-
CheckContext(Type)
-
CreateGlobalFunctions()
-
CreateGlobalFunctionsNoLock()
-
DefineDocument(string, Guid, Guid, Guid)
-
DefineDocumentNoLock(string, Guid, Guid, Guid)
-
DefineEnum(string, TypeAttributes, Type)
-
DefineEnumNoLock(string, TypeAttributes, Type)
-
DefineGlobalMethod(string, MethodAttributes, CallingConventions, Type, Type)
-
DefineGlobalMethod(string, MethodAttributes, CallingConventions, Type, Type, Type, Type, Type, Type)
-
DefineGlobalMethod(string, MethodAttributes, Type, Type)
-
DefineGlobalMethodNoLock(string, MethodAttributes, CallingConventions, Type, Type, Type, Type, Type, Type)
-
DefineInitializedData(string, byte, FieldAttributes)
-
DefineInitializedDataNoLock(string, byte, FieldAttributes)
-
DefineManifestResource(string, Stream, ResourceAttributes)
-
DefineManifestResourceNoLock(string, Stream, ResourceAttributes)
-
DefinePInvokeMethod(string, string, MethodAttributes, CallingConventions, Type, Type, CallingConvention, CharSet)
-
DefinePInvokeMethod(string, string, string, MethodAttributes, CallingConventions, Type, Type, CallingConvention, CharSet)
-
DefinePInvokeMethodNoLock(string, string, string, MethodAttributes, CallingConventions, Type, Type, CallingConvention, CharSet)
-
DefineResource(string, string)
-
DefineResource(string, string, ResourceAttributes)
-
DefineResourceNoLock(string, string, ResourceAttributes)
-
DefineType(string)
-
DefineType(string, TypeAttributes)
-
DefineType(string, TypeAttributes, Type)
-
DefineType(string, TypeAttributes, Type, int)
-
DefineType(string, TypeAttributes, Type, PackingSize)
-
DefineType(string, TypeAttributes, Type, PackingSize, int)
-
DefineType(string, TypeAttributes, Type, Type)
-
DefineTypeNoLock(string)
-
DefineTypeNoLock(string, TypeAttributes)
-
DefineTypeNoLock(string, TypeAttributes, Type)
-
DefineTypeNoLock(string, TypeAttributes, Type, int)
-
DefineTypeNoLock(string, TypeAttributes, Type, PackingSize)
-
DefineTypeNoLock(string, TypeAttributes, Type, PackingSize, int)
-
DefineTypeNoLock(string, TypeAttributes, Type, Type)
-
DefineUninitializedData(string, int, FieldAttributes)
-
DefineUninitializedDataNoLock(string, int, FieldAttributes)
-
DefineUnmanagedResource(byte)
-
DefineUnmanagedResource(string)
-
DefineUnmanagedResourceFileInternal(string)
-
FindTypeBuilderWithName(string, bool)
-
FullyQualifiedName()
-
GetArrayMethod(Type, string, CallingConventions, Type, Type)
-
GetArrayMethodToken(Type, string, CallingConventions, Type, Type)
-
GetArrayMethodTokenNoLock(Type, string, CallingConventions, Type, Type)
-
GetConstructorToken(ConstructorInfo)
-
GetFieldToken(FieldInfo)
-
GetFieldTokenNoLock(FieldInfo)
-
GetIDsOfNames(Guid, IntPtr, uint, uint, IntPtr)
-
GetMethodToken(MethodInfo)
-
GetMethodTokenNoLock(MethodInfo)
-
GetRootElementType(Type)
-
GetSignatureToken(byte, int)
-
GetSignatureToken(SignatureHelper)
-
GetStringConstant(string)
-
GetSymWriter()
-
GetType(string)
-
GetType(string, bool)
-
GetType(string, bool, bool)
-
GetType(string, Type)
-
GetTypeInfo(uint, uint, IntPtr)
-
GetTypeInfoCount(uint)
-
GetTypeNoLock(string, bool, bool)
-
GetTypeRefNested(Type, Module, string)
-
GetTypes()
-
GetTypeToken(string)
-
GetTypeToken(Type)
-
GetTypeTokenNoLock(Type)
-
Init(string, string, ISymbolWriter)
-
InternalGetConstructorToken(ConstructorInfo, bool)
-
Invoke(uint, Guid, uint, short, IntPtr, IntPtr, IntPtr, IntPtr)
-
IsTransient()
-
ModuleBuilder()
-
PreSave(string, PortableExecutableKinds, ImageFileMachine)
-
PreSaveNoLock(string, PortableExecutableKinds, ImageFileMachine)
-
Save(string, bool, PortableExecutableKinds, ImageFileMachine)
-
SaveNoLock(string, bool, PortableExecutableKinds, ImageFileMachine)
-
SetCustomAttribute(ConstructorInfo, byte)
-
SetCustomAttribute(CustomAttributeBuilder)
-
SetEntryPoint(MethodInfo)
-
SetSymCustomAttribute(string, byte)
-
SetSymCustomAttributeNoLock(string, byte)
-
SetUserEntryPoint(MethodInfo)
-
SetUserEntryPointNoLock(MethodInfo)
-
UnmangleTypeName(string)
-
Expand
ModuleBuilderData
-
Expand
OpCode
-
Expand
OpCodes
-
Expand
OpCodeType
-
Expand
OperandType
-
Expand
PackingSize
-
Expand
ParameterBuilder
-
Expand
ParameterToken
-
Expand
PEFileKinds
-
Expand
PropertyBuilder
-
Expand
PropertyToken
-
Expand
REDocument
-
Expand
ResWriterData
-
Expand
RTDynamicMethod
-
Expand
ScopeAction
-
Expand
ScopeTree
-
Expand
SecurityControlFlags
-
Expand
SignatureHelper
-
Expand
SignatureToken
-
Expand
StackBehaviour
-
Expand
StringToken
-
Expand
SymbolMethod
-
Expand
SymbolType
-
Expand
SymCustomAttr
-
Expand
TypeBuilder
-
Expand
TypeBuilderInstantiation
-
Expand
TypeKind
-
Expand
TypeNameBuilder
-
Expand
TypeToken
-
Expand
UnmanagedMarshal
-
Expand
VarArgMethod
-
Expand
System.Resources
-
Expand
System.Runtime
-
Expand
System.Runtime.InteropServices.Expando
-
Expand
System.Runtime.ConstrainedExecution
-
Expand
System.Runtime.Remoting.Activation
-
Expand
System.Runtime.Remoting.Messaging
-
Expand
System.Runtime.Remoting.Channels
-
Expand
System.Runtime.Remoting.Lifetime
-
Expand
System.Runtime.Remoting
-
Expand
System.Runtime.Remoting.Contexts
-
Expand
System.Runtime.Remoting.Proxies
-
Expand
System.Runtime.Remoting.Metadata
-
Expand
System.Runtime.Remoting.Metadata.W3cXsd2001
-
Expand
System.Runtime.Remoting.Services
-
Expand
System.Runtime.Serialization
-
Expand
System.Runtime.Serialization.Formatters
-
Expand
System.Runtime.Serialization.Formatters.Binary
-
Expand
System.Runtime.Versioning
-
Expand
System.Security
-
Expand
System.Security.Cryptography
-
Expand
System.Security.Cryptography.X509Certificates
-
Expand
System.Security.Permissions
-
Expand
System.Security.Policy
-
Expand
System.Security.Principal
-
Expand
System.Security.Util
-
Expand
System.Text
-
Expand
System.Threading
-
Expand
System.Runtime.Remoting.Channels.Http
-
Expand
System.Runtime.Remoting.Channels.Tcp
-
Expand
System.Runtime.Remoting.MetadataServices
-
Expand
System.Runtime.Serialization.Formatters.Soap.Xml
-
Expand
System.Runtime.Serialization.Formatters.Soap
-
Expand
Microsoft.Tools.Caspol
-
Expand
Microsoft.Tools.Build
-
Expand
Microsoft.CSharp
-
Expand
System.CodeDom
-
Expand
System.CodeDom.Compiler
-
Expand
System.Collections.Specialized
-
Expand
System.ComponentModel
-
Expand
System.ComponentModel.Design
-
Expand
System.ComponentModel.Design.Serialization
-
Expand
System.Configuration
-
Expand
System.Web
-
Expand
System.Configuration.Provider
-
Expand
System.Configuration.Internal
-
Expand
System.Internal
-
Expand
System.Windows.Forms
-
Expand
System.Net
-
Expand
System.Net.Sockets
-
Expand
System.Net.NetworkInformation
-
Expand
System.Net.ComImports
-
Expand
System.Net.Security
-
Expand
System.Net.Cache
-
Expand
System.Net.Configuration
-
Expand
System.Text.RegularExpressions
-
Expand
System.Tools
-
Expand
System.IO.Compression
-
Expand
System.IO.Ports
-
Expand
System.Security.AccessControl
-
Expand
System.Xml
-
Expand
System.Xml.XPath.DataBinding
-
Expand
System.Xml.Schema
-
Expand
System.Xml.Serialization
-
Expand
System.Xml.Serialization.Advanced
-
Expand
System.Xml.Serialization.Configuration
-
Expand
System.Xml.XPath
-
Expand
System.Xml.Xsl
-
Expand
System.Xml.Xsl.IlGen
-
Expand
System.Xml.Xsl.Qil
-
Expand
System.Xml.Xsl.Runtime
-
Expand
System.Xml.Xsl.XPath
-
Expand
System.Xml.Xsl.Xslt
-
Expand
System.Xml.Xsl.XsltOld
-
Expand
System.Xml.Xsl.XsltOld.Debugger
-
Expand
Microsoft.JScript
-
Expand
Microsoft.Vsa
-
Expand
Microsoft.JScript.Vsa
- namespace System.Reflection.Emit
- {
- using System.Runtime.InteropServices;
- using System;
- using IList = System.Collections.IList;
- using ArrayList = System.Collections.ArrayList;
- using CultureInfo = System.Globalization.CultureInfo;
- using ResourceWriter = System.Resources.ResourceWriter;
- using IResourceWriter = System.Resources.IResourceWriter;
- using System.Diagnostics.SymbolStore;
- using System.Reflection;
- using System.Diagnostics;
- using System.IO;
- using System.Security;
- using System.Security.Permissions;
- using System.Runtime.Serialization;
- using System.Text;
- using System.Threading;
- using System.Runtime.Versioning;
-
-
- [HostProtection(MayLeakOnAbort = true)]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_ModuleBuilder))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public class ModuleBuilder : Module, _ModuleBuilder
- {
- #region Internal Static Members
- static internal string UnmangleTypeName(string typeName)
- {
-
-
- int i = typeName.Length - 1;
- while (true) {
- i = typeName.LastIndexOf('+', i);
- if (i == -1)
- break;
-
- bool evenSlashes = true;
- int iSlash = i;
- while (typeName[--iSlash] == '\\')
- evenSlashes = !evenSlashes;
-
-
- if (evenSlashes)
- break;
-
- i = iSlash;
- }
-
- return typeName.Substring(i + 1);
- }
-
- #endregion
-
- #region Private Data Members
-
-
- #endregion
-
- #region Constructor
- private ModuleBuilder()
- {
- }
-
- #endregion
-
- #region Private Members
- private Type GetType(string strFormat, Type baseType)
- {
-
-
- if (strFormat == null || strFormat.Equals(String.Empty)) {
- return baseType;
- }
-
-
- char[] bFormat = strFormat.ToCharArray();
- return SymbolType.FormCompoundType(bFormat, baseType, 0);
-
- }
-
-
- internal void CheckContext(params Type[][] typess)
- {
- ((AssemblyBuilder)Assembly).CheckContext(typess);
- }
- internal void CheckContext(params Type[] types)
- {
- ((AssemblyBuilder)Assembly).CheckContext(types);
- }
- #endregion
-
- #region Internal Members
- internal virtual Type FindTypeBuilderWithName(string strTypeName, bool ignoreCase)
- {
- int size = m_TypeBuilderList.Count;
- int i;
- Type typeTemp = null;
-
- for (i = 0; i < size; i++) {
- typeTemp = (Type)m_TypeBuilderList[i];
- if (ignoreCase == true) {
- if (String.Compare(typeTemp.FullName, strTypeName, ((ignoreCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) == 0)
- break;
- }
- else {
- if (typeTemp.FullName.Equals(strTypeName))
- break;
- }
- }
- if (i == size)
- typeTemp = null;
-
- return typeTemp;
- }
-
- internal Type GetRootElementType(Type type)
- {
-
- if (type.IsByRef == false && type.IsPointer == false && type.IsArray == false)
- return type;
-
- return GetRootElementType(type.GetElementType());
- }
-
- internal void SetEntryPoint(MethodInfo entryPoint)
- {
-
-
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- m_EntryPoint = GetMethodToken(entryPoint);
- }
-
-
- internal void PreSave(string fileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- PreSaveNoLock(fileName, portableExecutableKind, imageFileMachine);
- }
- }
- else {
- PreSaveNoLock(fileName, portableExecutableKind, imageFileMachine);
- }
- }
-
- private void PreSaveNoLock(string fileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
-
- object item;
- TypeBuilder typeBuilder;
- if (m_moduleData.m_isSaved == true) {
-
- throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Environment.GetResourceString("InvalidOperation_ModuleHasBeenSaved"), m_moduleData.m_strModuleName));
- }
-
- if (m_moduleData.m_fGlobalBeenCreated == false && m_moduleData.m_fHasGlobal == true)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_GlobalFunctionNotBaked"));
-
- int size = m_TypeBuilderList.Count;
- for (int i = 0; i < size; i++) {
- item = m_TypeBuilderList[i];
- if (item is TypeBuilder) {
- typeBuilder = (TypeBuilder)item;
- }
- else {
- EnumBuilder enumBuilder = (EnumBuilder)item;
- typeBuilder = enumBuilder.m_typeBuilder;
- }
- if (typeBuilder.m_hasBeenCreated == false && typeBuilder.m_isHiddenType == false) {
-
- throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, Environment.GetResourceString("NotSupported_NotAllTypesAreBaked"), typeBuilder.FullName));
- }
- }
-
- InternalPreSavePEFile((int)portableExecutableKind, (int)imageFileMachine);
- }
-
- internal void Save(string fileName, bool isAssemblyFile, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- SaveNoLock(fileName, isAssemblyFile, portableExecutableKind, imageFileMachine);
- }
- }
- else {
- SaveNoLock(fileName, isAssemblyFile, portableExecutableKind, imageFileMachine);
- }
- }
-
- private void SaveNoLock(string fileName, bool isAssemblyFile, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
-
- if (m_moduleData.m_embeddedRes != null) {
-
- ResWriterData resWriter;
- int iCount;
-
-
- for (resWriter = m_moduleData.m_embeddedRes,iCount = 0; resWriter != null; resWriter = resWriter.m_nextResWriter,iCount++)
- ;
- InternalSetResourceCounts(iCount);
-
-
- for (resWriter = m_moduleData.m_embeddedRes; resWriter != null; resWriter = resWriter.m_nextResWriter) {
- if (resWriter.m_resWriter != null)
- resWriter.m_resWriter.Generate();
-
- byte[] resBytes = new byte[resWriter.m_memoryStream.Length];
- resWriter.m_memoryStream.Flush();
- resWriter.m_memoryStream.Position = 0;
- resWriter.m_memoryStream.Read(resBytes, 0, resBytes.Length);
- InternalAddResource(resWriter.m_strName, resBytes, resBytes.Length, m_moduleData.m_tkFile, (int)resWriter.m_attribute, (int)portableExecutableKind, (int)imageFileMachine);
- }
- }
-
-
- if (isAssemblyFile)
- InternalSavePEFile(fileName, m_EntryPoint, (int)Assembly.m_assemblyData.m_peFileKind, true);
- else
- InternalSavePEFile(fileName, m_EntryPoint, (int)PEFileKinds.Dll, false);
- m_moduleData.m_isSaved = true;
- }
-
- internal int GetTypeRefNested(Type type, Module refedModule, string strRefedModuleFileName)
- {
-
-
- Type enclosingType = type.DeclaringType;
- int tkResolution = 0;
- string typeName = type.FullName;
-
- if (enclosingType != null) {
- tkResolution = GetTypeRefNested(enclosingType, refedModule, strRefedModuleFileName);
- typeName = UnmangleTypeName(typeName);
- }
-
- return InternalGetTypeToken(typeName, refedModule, strRefedModuleFileName, tkResolution);
- }
-
- internal MethodToken InternalGetConstructorToken(ConstructorInfo con, bool usingRef)
- {
-
-
-
- int tr;
- int mr = 0;
-
- if (con == null)
- throw new ArgumentNullException("con");
-
- if (con is ConstructorBuilder) {
- ConstructorBuilder conBuilder = con as ConstructorBuilder;
- if (usingRef == false && conBuilder.ReflectedType.Module.Equals(this))
- return conBuilder.GetToken();
-
-
- tr = GetTypeToken(con.ReflectedType).Token;
- mr = InternalGetMemberRef(con.ReflectedType.Module, tr, conBuilder.GetToken().Token);
- }
- else if (con is ConstructorOnTypeBuilderInstantiation) {
- ConstructorOnTypeBuilderInstantiation conBuilder = con as ConstructorOnTypeBuilderInstantiation;
- if (usingRef == true)
- throw new InvalidOperationException();
-
- tr = GetTypeToken(con.DeclaringType).Token;
- mr = InternalGetMemberRef(con.DeclaringType.Module, tr, conBuilder.m_ctor.MetadataTokenInternal);
- }
- else if (con is RuntimeConstructorInfo && con.ReflectedType.IsArray == false) {
-
-
-
- tr = GetTypeToken(con.ReflectedType).Token;
- mr = InternalGetMemberRefOfMethodInfo(tr, con.GetMethodHandle());
- }
- else {
-
-
- ParameterInfo[] parameters = con.GetParameters();
- Type[] parameterTypes = new Type[parameters.Length];
- Type[][] requiredCustomModifiers = new Type[parameterTypes.Length][];
- Type[][] optionalCustomModifiers = new Type[parameterTypes.Length][];
-
- for (int i = 0; i < parameters.Length; i++) {
- parameterTypes[i] = parameters[i].ParameterType;
- requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers();
- optionalCustomModifiers[i] = parameters[i].GetOptionalCustomModifiers();
- }
-
- tr = GetTypeToken(con.ReflectedType).Token;
-
- SignatureHelper sigHelp = SignatureHelper.GetMethodSigHelper(this, con.CallingConvention, null, null, null, parameterTypes, requiredCustomModifiers, optionalCustomModifiers);
- int length;
- byte[] sigBytes = sigHelp.InternalGetSignature(out length);
-
- mr = InternalGetMemberRefFromSignature(tr, con.Name, sigBytes, length);
- }
-
- return new MethodToken(mr);
- }
-
- internal void Init(string strModuleName, string strFileName, ISymbolWriter writer)
- {
- m_moduleData = new ModuleBuilderData(this, strModuleName, strFileName);
- m_TypeBuilderList = new ArrayList();
- m_iSymWriter = writer;
-
- if (writer != null) {
-
-
-
- new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
- writer.SetUnderlyingWriter(m_pInternalSymWriter);
- }
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- internal void DefineUnmanagedResourceFileInternal(string resourceFileName)
- {
-
-
- if (m_moduleData.m_resourceBytes != null)
- throw new ArgumentException(Environment.GetResourceString("Argument_NativeResourceAlreadyDefined"));
-
- if (resourceFileName == null)
- throw new ArgumentNullException("resourceFileName");
-
- if (m_moduleData.m_fHasExplicitUnmanagedResource)
- throw new ArgumentException(Environment.GetResourceString("Argument_NativeResourceAlreadyDefined"));
-
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
-
-
- string strFullFileName;
- strFullFileName = Path.GetFullPath(resourceFileName);
- new FileIOPermission(FileIOPermissionAccess.Read, strFullFileName).Demand();
-
- new EnvironmentPermission(PermissionState.Unrestricted).Assert();
- try {
- if (File.Exists(resourceFileName) == false)
- throw new FileNotFoundException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("IO.FileNotFound_FileName"), resourceFileName), resourceFileName);
- }
- finally {
- CodeAccessPermission.RevertAssert();
- }
-
- m_moduleData.m_strResourceFileName = strFullFileName;
- }
-
- #endregion
-
- #region Module Overrides
- public override Type[] GetTypes()
- {
- int size = m_TypeBuilderList.Count;
- Type[] moduleTypes = new Type[size];
- TypeBuilder tmpTypeBldr;
- int filtered = 0;
-
- for (int i = 0; i < size; i++) {
- EnumBuilder enumBldr = m_TypeBuilderList[i] as EnumBuilder;
- tmpTypeBldr = m_TypeBuilderList[i] as TypeBuilder;
- if (enumBldr != null)
- tmpTypeBldr = enumBldr.m_typeBuilder;
-
- if (tmpTypeBldr != null) {
- if (tmpTypeBldr.m_hasBeenCreated)
- moduleTypes[i] = tmpTypeBldr.UnderlyingSystemType;
- else
- moduleTypes[i] = tmpTypeBldr;
- }
- else {
-
- moduleTypes[i] = (Type)m_TypeBuilderList[i];
- }
- }
-
- if (filtered > 0) {
- Type[] filteredTypes = new Type[size - filtered];
- int src;
- int dst;
- for (src = 0,dst = 0; src < size; src++) {
- if (moduleTypes[src] != null) {
- filteredTypes[dst] = moduleTypes[src];
- dst++;
- }
- }
- moduleTypes = filteredTypes;
- }
-
- return moduleTypes;
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public override Type GetType(string className)
- {
- return GetType(className, false, false);
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public override Type GetType(string className, bool ignoreCase)
- {
- return GetType(className, false, ignoreCase);
- }
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public override Type GetType(string className, bool throwOnError, bool ignoreCase)
- {
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- return GetTypeNoLock(className, throwOnError, ignoreCase);
- }
- }
- else {
- return GetTypeNoLock(className, throwOnError, ignoreCase);
- }
- }
-
- private Type GetTypeNoLock(string className, bool throwOnError, bool ignoreCase)
- {
-
-
-
-
-
-
-
-
- Type baseType = base.GetType(className, throwOnError, ignoreCase);
- if (baseType != null)
- return baseType;
-
-
-
-
- string baseName = null;
- string parameters = null;
- int startIndex = 0;
-
- while (startIndex <= className.Length) {
-
- int i = className.IndexOfAny(new char[] {'[', '*', '&'}, startIndex);
- if (i == -1) {
-
- baseName = className;
- parameters = null;
- break;
- }
-
-
- int slashes = 0;
- for (int j = i - 1; j >= 0 && className[j] == '\\'; j--)
- slashes++;
-
-
- if (slashes % 2 == 1) {
- startIndex = i + 1;
- continue;
- }
-
-
- baseName = className.Substring(0, i);
- parameters = className.Substring(i);
- break;
- }
-
-
-
- if (baseName == null) {
- baseName = className;
- parameters = null;
- }
-
- baseName = baseName.Replace("\\\\", "\\").Replace("\\[", "[").Replace("\\*", "*").Replace("\\&", "&");
-
- if (parameters != null) {
-
-
-
- baseType = base.GetType(baseName, false, ignoreCase);
- }
-
- if (baseType == null) {
-
-
- baseType = FindTypeBuilderWithName(baseName, ignoreCase);
- if (baseType == null && Assembly is AssemblyBuilder) {
-
- int size;
- ArrayList modList;
-
- modList = Assembly.m_assemblyData.m_moduleBuilderList;
- size = modList.Count;
- for (int i = 0; i < size && baseType == null; i++) {
- ModuleBuilder mBuilder = (ModuleBuilder)modList[i];
- baseType = mBuilder.FindTypeBuilderWithName(baseName, ignoreCase);
- }
- }
- if (baseType == null)
- return null;
- }
-
- if (parameters == null)
- return baseType;
-
- return GetType(parameters, baseType);
- }
-
- public override string FullyQualifiedName {
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- get {
- string fullyQualifiedName = m_moduleData.m_strFileName;
- if (fullyQualifiedName == null)
- return null;
- if (Assembly.m_assemblyData.m_strDir != null) {
- fullyQualifiedName = Path.Combine(Assembly.m_assemblyData.m_strDir, fullyQualifiedName);
- fullyQualifiedName = Path.GetFullPath(fullyQualifiedName);
- }
-
- if (Assembly.m_assemblyData.m_strDir != null && fullyQualifiedName != null) {
- new FileIOPermission(FileIOPermissionAccess.PathDiscovery, fullyQualifiedName).Demand();
- }
-
- return fullyQualifiedName;
- }
- }
-
- #endregion
-
- #region Public Members
-
- #region Define Type
- public TypeBuilder DefineType(string name)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- return DefineTypeNoLock(name);
- }
- }
- else {
- return DefineTypeNoLock(name);
- }
- }
-
- private TypeBuilder DefineTypeNoLock(string name)
- {
- TypeBuilder typeBuilder;
- typeBuilder = new TypeBuilder(name, TypeAttributes.NotPublic, null, null, this, PackingSize.Unspecified, null);
- m_TypeBuilderList.Add(typeBuilder);
- return typeBuilder;
- }
-
- public TypeBuilder DefineType(string name, TypeAttributes attr)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- return DefineTypeNoLock(name, attr);
- }
- }
- else {
- return DefineTypeNoLock(name, attr);
- }
- }
-
- private TypeBuilder DefineTypeNoLock(string name, TypeAttributes attr)
- {
- TypeBuilder typeBuilder;
- typeBuilder = new TypeBuilder(name, attr, null, null, this, PackingSize.Unspecified, null);
- m_TypeBuilderList.Add(typeBuilder);
- return typeBuilder;
- }
-
- public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- return DefineTypeNoLock(name, attr, parent);
- }
- }
- else {
- return DefineTypeNoLock(name, attr, parent);
- }
- }
-
- private TypeBuilder DefineTypeNoLock(string name, TypeAttributes attr, Type parent)
- {
- CheckContext(parent);
-
- TypeBuilder typeBuilder;
-
- typeBuilder = new TypeBuilder(name, attr, parent, null, this, PackingSize.Unspecified, null);
- m_TypeBuilderList.Add(typeBuilder);
- return typeBuilder;
- }
-
- public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, int typesize)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (Assembly.m_assemblyData.m_isSynchronized) {
- lock (Assembly.m_assemblyData) {
- return DefineTypeNoLock(name, attr, parent, typesize);
- }
- }
- else {
-