Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / clr / src / BCL / System / Reflection / Emit / ModuleBuilderData.cs / 1305376 / ModuleBuilderData.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// [....]
//
namespace System.Reflection.Emit
{
using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
// This is a package private class. This class hold all of the managed
// data member for ModuleBuilder. Note that what ever data members added to
// this class cannot be accessed from the EE.
[Serializable]
internal class ModuleBuilderData
{
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal ModuleBuilderData(ModuleBuilder module, String strModuleName, String strFileName, int tkFile)
{
m_globalTypeBuilder = new TypeBuilder(module);
m_module = module;
m_tkFile = tkFile;
InitNames(strModuleName, strFileName);
}
// Initialize module and file names.
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
private void InitNames(String strModuleName, String strFileName)
{
m_strModuleName = strModuleName;
if (strFileName == null)
{
// fake a transient module file name
m_strFileName = strModuleName;
}
else
{
String strExtension = Path.GetExtension(strFileName);
if (strExtension == null || strExtension == String.Empty)
{
// This is required by our loader. It cannot load module file that does not have file extension.
throw new ArgumentException(Environment.GetResourceString("Argument_NoModuleFileExtension", strFileName));
}
m_strFileName = strFileName;
}
}
// This is a method for changing module and file name of the manifest module (created by default for
// each assembly).
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal virtual void ModifyModuleName(String strModuleName)
{
Contract.Assert(m_strModuleName == AssemblyBuilder.MANIFEST_MODULE_NAME, "Changing names for non-manifest module");
InitNames(strModuleName, null /*strFileName*/);
}
internal int FileToken
{
get
{
// Before save, the scope of m_tkFile is the in-memory assembly manifest
// During save, the scope of m_tkFile is the on-disk assembly manifest
// For transient modules m_tkFile never change.
// Theoretically no one should emit anything after a dynamic assembly has
// been saved. So m_tkFile shouldn't used when m_isSaved is true.
// But that was never completely enforced: you can still emit everything after
// the assembly has been saved (except for public types in persistent modules).
return m_tkFile;
}
set
{
m_tkFile = value;
}
}
internal String m_strModuleName; // scope name (can be different from file name)
internal String m_strFileName;
internal bool m_fGlobalBeenCreated;
internal bool m_fHasGlobal;
[NonSerialized]
internal TypeBuilder m_globalTypeBuilder;
[NonSerialized]
internal ModuleBuilder m_module;
private int m_tkFile;
internal bool m_isSaved;
[NonSerialized]
internal ResWriterData m_embeddedRes;
internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$";
internal String m_strResourceFileName;
internal byte[] m_resourceBytes;
} // class ModuleBuilderData
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// [....]
//
namespace System.Reflection.Emit
{
using System;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
// This is a package private class. This class hold all of the managed
// data member for ModuleBuilder. Note that what ever data members added to
// this class cannot be accessed from the EE.
[Serializable]
internal class ModuleBuilderData
{
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal ModuleBuilderData(ModuleBuilder module, String strModuleName, String strFileName, int tkFile)
{
m_globalTypeBuilder = new TypeBuilder(module);
m_module = module;
m_tkFile = tkFile;
InitNames(strModuleName, strFileName);
}
// Initialize module and file names.
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
private void InitNames(String strModuleName, String strFileName)
{
m_strModuleName = strModuleName;
if (strFileName == null)
{
// fake a transient module file name
m_strFileName = strModuleName;
}
else
{
String strExtension = Path.GetExtension(strFileName);
if (strExtension == null || strExtension == String.Empty)
{
// This is required by our loader. It cannot load module file that does not have file extension.
throw new ArgumentException(Environment.GetResourceString("Argument_NoModuleFileExtension", strFileName));
}
m_strFileName = strFileName;
}
}
// This is a method for changing module and file name of the manifest module (created by default for
// each assembly).
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
internal virtual void ModifyModuleName(String strModuleName)
{
Contract.Assert(m_strModuleName == AssemblyBuilder.MANIFEST_MODULE_NAME, "Changing names for non-manifest module");
InitNames(strModuleName, null /*strFileName*/);
}
internal int FileToken
{
get
{
// Before save, the scope of m_tkFile is the in-memory assembly manifest
// During save, the scope of m_tkFile is the on-disk assembly manifest
// For transient modules m_tkFile never change.
// Theoretically no one should emit anything after a dynamic assembly has
// been saved. So m_tkFile shouldn't used when m_isSaved is true.
// But that was never completely enforced: you can still emit everything after
// the assembly has been saved (except for public types in persistent modules).
return m_tkFile;
}
set
{
m_tkFile = value;
}
}
internal String m_strModuleName; // scope name (can be different from file name)
internal String m_strFileName;
internal bool m_fGlobalBeenCreated;
internal bool m_fHasGlobal;
[NonSerialized]
internal TypeBuilder m_globalTypeBuilder;
[NonSerialized]
internal ModuleBuilder m_module;
private int m_tkFile;
internal bool m_isSaved;
[NonSerialized]
internal ResWriterData m_embeddedRes;
internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$";
internal String m_strResourceFileName;
internal byte[] m_resourceBytes;
} // class ModuleBuilderData
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- InternalSafeNativeMethods.cs
- PatternMatcher.cs
- SafeNativeMethods.cs
- ToolStripControlHost.cs
- ThreadStateException.cs
- FileDataSourceCache.cs
- DocumentEventArgs.cs
- InstanceNormalEvent.cs
- Table.cs
- httpserverutility.cs
- CellQuery.cs
- CreateUserErrorEventArgs.cs
- SoapIncludeAttribute.cs
- CreateUserWizardStep.cs
- MenuItemBinding.cs
- figurelength.cs
- ParameterRetriever.cs
- SessionSwitchEventArgs.cs
- AppDomainUnloadedException.cs
- InvokePattern.cs
- ElementsClipboardData.cs
- HashAlgorithm.cs
- Manipulation.cs
- PrintPreviewControl.cs
- TrustLevel.cs
- HttpValueCollection.cs
- Int64Converter.cs
- CodeRegionDirective.cs
- GridViewDeletedEventArgs.cs
- RoutedUICommand.cs
- StartUpEventArgs.cs
- SlotInfo.cs
- PrintEvent.cs
- RangeBase.cs
- IPEndPointCollection.cs
- ParseElement.cs
- SQLBytesStorage.cs
- X509Utils.cs
- TextBoxDesigner.cs
- WebRequestModulesSection.cs
- WebEventTraceProvider.cs
- WindowsAuthenticationEventArgs.cs
- XmlSchemaSequence.cs
- ImageAttributes.cs
- oledbmetadatacollectionnames.cs
- DynamicILGenerator.cs
- RootNamespaceAttribute.cs
- PrintPreviewControl.cs
- AppSettingsReader.cs
- ResourceAttributes.cs
- TextBoxLine.cs
- MediaSystem.cs
- GenericTextProperties.cs
- MailAddressCollection.cs
- TableAutomationPeer.cs
- AsyncWaitHandle.cs
- DataObjectMethodAttribute.cs
- XmlUtil.cs
- SerializableAttribute.cs
- LongPath.cs
- ControlEvent.cs
- LinqDataSourceSelectEventArgs.cs
- SBCSCodePageEncoding.cs
- TextParaClient.cs
- ObjectAnimationUsingKeyFrames.cs
- XmlDataSourceDesigner.cs
- _NestedSingleAsyncResult.cs
- HttpProtocolReflector.cs
- COM2PictureConverter.cs
- WCFBuildProvider.cs
- DataGridViewColumnHeaderCell.cs
- UnsafeNativeMethods.cs
- WizardStepBase.cs
- HtmlControlPersistable.cs
- TaiwanLunisolarCalendar.cs
- TimelineCollection.cs
- ValueUtilsSmi.cs
- XmlWrappingReader.cs
- RawTextInputReport.cs
- SrgsOneOf.cs
- ControlCachePolicy.cs
- EdmItemCollection.OcAssemblyCache.cs
- ObjectHandle.cs
- ObjectIDGenerator.cs
- DefaultEventAttribute.cs
- EditorPartCollection.cs
- TextElement.cs
- ContentPathSegment.cs
- EUCJPEncoding.cs
- PeekCompletedEventArgs.cs
- TextServicesProperty.cs
- TypeInitializationException.cs
- ALinqExpressionVisitor.cs
- TextTreeExtractElementUndoUnit.cs
- exports.cs
- DataGridViewBindingCompleteEventArgs.cs
- BrowserInteropHelper.cs
- RTLAwareMessageBox.cs
- MultipleViewProviderWrapper.cs
- ColorIndependentAnimationStorage.cs