Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / Reflection / Emit / LocalBuilder.cs / 1 / LocalBuilder.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
using System.Reflection;
using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.Reflection.Emit
{
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_LocalBuilder))]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class LocalBuilder : LocalVariableInfo, _LocalBuilder
{
#region Private Data Members
private int m_localIndex;
private Type m_localType;
private MethodInfo m_methodBuilder;
private bool m_isPinned;
#endregion
#region Constructor
private LocalBuilder() { }
internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder)
: this(localIndex, localType, methodBuilder, false) { }
internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned)
{
m_isPinned = isPinned;
m_localIndex = localIndex;
m_localType = localType;
m_methodBuilder = methodBuilder;
}
#endregion
#region Internal Members
internal int GetLocalIndex()
{
return m_localIndex;
}
internal MethodInfo GetMethodBuilder()
{
return m_methodBuilder;
}
#endregion
#region LocalVariableInfo Override
public override bool IsPinned { get { return m_isPinned; } }
public override Type LocalType
{
get
{
return m_localType;
}
}
public override int LocalIndex { get { return m_localIndex; } }
#endregion
#region Public Members
public void SetLocalSymInfo(String name)
{
SetLocalSymInfo(name, 0, 0);
}
public void SetLocalSymInfo(String name, int startOffset, int endOffset)
{
ModuleBuilder dynMod;
SignatureHelper sigHelp;
int sigLength;
byte[] signature;
byte[] mungedSig;
int index;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
if (methodBuilder == null)
// it's a light code gen entity
throw new NotSupportedException();
dynMod = (ModuleBuilder) methodBuilder.Module;
if (methodBuilder.IsTypeCreated())
{
// cannot change method after its containing type has been created
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
}
// set the name and range of offset for the local
if (dynMod.GetSymWriter() == null)
{
// cannot set local name if not debug module
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
}
sigHelp = SignatureHelper.GetFieldSigHelper(dynMod);
sigHelp.AddArgument(m_localType);
signature = sigHelp.InternalGetSignature(out sigLength);
// The symbol store doesn't want the calling convention on the
// front of the signature, but InternalGetSignature returns
// the callinging convention. So we strip it off. This is a
// bit unfortunate, since it means that we need to allocate
// yet another array of bytes...
mungedSig = new byte[sigLength - 1];
Array.Copy(signature, 1, mungedSig, 0, sigLength - 1);
index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
if (index == -1)
{
// top level scope information is kept with methodBuilder
methodBuilder.m_localSymInfo.AddLocalSymInfo(
name,
mungedSig,
m_localIndex,
startOffset,
endOffset);
}
else
{
methodBuilder.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope(
name,
mungedSig,
m_localIndex,
startOffset,
endOffset);
}
}
#endregion
void _LocalBuilder.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
}
void _LocalBuilder.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException();
}
void _LocalBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException();
}
void _LocalBuilder.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
using System;
using System.Reflection;
using System.Security.Permissions;
using System.Runtime.InteropServices;
namespace System.Reflection.Emit
{
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(_LocalBuilder))]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class LocalBuilder : LocalVariableInfo, _LocalBuilder
{
#region Private Data Members
private int m_localIndex;
private Type m_localType;
private MethodInfo m_methodBuilder;
private bool m_isPinned;
#endregion
#region Constructor
private LocalBuilder() { }
internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder)
: this(localIndex, localType, methodBuilder, false) { }
internal LocalBuilder(int localIndex, Type localType, MethodInfo methodBuilder, bool isPinned)
{
m_isPinned = isPinned;
m_localIndex = localIndex;
m_localType = localType;
m_methodBuilder = methodBuilder;
}
#endregion
#region Internal Members
internal int GetLocalIndex()
{
return m_localIndex;
}
internal MethodInfo GetMethodBuilder()
{
return m_methodBuilder;
}
#endregion
#region LocalVariableInfo Override
public override bool IsPinned { get { return m_isPinned; } }
public override Type LocalType
{
get
{
return m_localType;
}
}
public override int LocalIndex { get { return m_localIndex; } }
#endregion
#region Public Members
public void SetLocalSymInfo(String name)
{
SetLocalSymInfo(name, 0, 0);
}
public void SetLocalSymInfo(String name, int startOffset, int endOffset)
{
ModuleBuilder dynMod;
SignatureHelper sigHelp;
int sigLength;
byte[] signature;
byte[] mungedSig;
int index;
MethodBuilder methodBuilder = m_methodBuilder as MethodBuilder;
if (methodBuilder == null)
// it's a light code gen entity
throw new NotSupportedException();
dynMod = (ModuleBuilder) methodBuilder.Module;
if (methodBuilder.IsTypeCreated())
{
// cannot change method after its containing type has been created
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
}
// set the name and range of offset for the local
if (dynMod.GetSymWriter() == null)
{
// cannot set local name if not debug module
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule"));
}
sigHelp = SignatureHelper.GetFieldSigHelper(dynMod);
sigHelp.AddArgument(m_localType);
signature = sigHelp.InternalGetSignature(out sigLength);
// The symbol store doesn't want the calling convention on the
// front of the signature, but InternalGetSignature returns
// the callinging convention. So we strip it off. This is a
// bit unfortunate, since it means that we need to allocate
// yet another array of bytes...
mungedSig = new byte[sigLength - 1];
Array.Copy(signature, 1, mungedSig, 0, sigLength - 1);
index = methodBuilder.GetILGenerator().m_ScopeTree.GetCurrentActiveScopeIndex();
if (index == -1)
{
// top level scope information is kept with methodBuilder
methodBuilder.m_localSymInfo.AddLocalSymInfo(
name,
mungedSig,
m_localIndex,
startOffset,
endOffset);
}
else
{
methodBuilder.GetILGenerator().m_ScopeTree.AddLocalSymInfoToCurrentScope(
name,
mungedSig,
m_localIndex,
startOffset,
endOffset);
}
}
#endregion
void _LocalBuilder.GetTypeInfoCount(out uint pcTInfo)
{
throw new NotImplementedException();
}
void _LocalBuilder.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
{
throw new NotImplementedException();
}
void _LocalBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException();
}
void _LocalBuilder.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
{
throw new NotImplementedException();
}
}
}
// 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
- ProgressChangedEventArgs.cs
- PersonalizableTypeEntry.cs
- UnmanagedMarshal.cs
- Quaternion.cs
- FunctionDetailsReader.cs
- LassoSelectionBehavior.cs
- StrongTypingException.cs
- Perspective.cs
- PageAsyncTask.cs
- TypeBuilderInstantiation.cs
- DataGridViewRow.cs
- xml.cs
- IconHelper.cs
- UrlMapping.cs
- OleDbSchemaGuid.cs
- Helpers.cs
- XmlWrappingReader.cs
- HwndAppCommandInputProvider.cs
- XmlDocumentFragment.cs
- ColorKeyFrameCollection.cs
- MsmqTransportSecurity.cs
- GridViewColumn.cs
- MultiTouchSystemGestureLogic.cs
- RowToParametersTransformer.cs
- Point3DCollection.cs
- EncoderReplacementFallback.cs
- PackageStore.cs
- ToolboxItemFilterAttribute.cs
- HttpCacheVaryByContentEncodings.cs
- IssuanceLicense.cs
- SafeBuffer.cs
- SkipStoryboardToFill.cs
- ToolStripPanel.cs
- MarginCollapsingState.cs
- KeyInterop.cs
- MemoryFailPoint.cs
- ColumnMapVisitor.cs
- _CommandStream.cs
- OdbcCommand.cs
- EncryptedReference.cs
- Timer.cs
- EventLogPermissionEntryCollection.cs
- Matrix3DConverter.cs
- BulletedList.cs
- XamlSerializerUtil.cs
- Pen.cs
- WindowExtensionMethods.cs
- DefaultExpressionVisitor.cs
- ScriptBehaviorDescriptor.cs
- ToolStripDropTargetManager.cs
- TextModifierScope.cs
- HttpListenerResponse.cs
- SQLResource.cs
- CharEnumerator.cs
- StrongNamePublicKeyBlob.cs
- DetailsViewAutoFormat.cs
- HostingEnvironmentException.cs
- ToolStripItemClickedEventArgs.cs
- PolicyStatement.cs
- SafeCryptoHandles.cs
- Span.cs
- BaseCodeDomTreeGenerator.cs
- DataGridCellInfo.cs
- DisableDpiAwarenessAttribute.cs
- XmlCodeExporter.cs
- ellipse.cs
- UserControlCodeDomTreeGenerator.cs
- SHA384Managed.cs
- CheckBox.cs
- CompoundFileIOPermission.cs
- FontFamilyIdentifier.cs
- Pair.cs
- SingleAnimationBase.cs
- TiffBitmapDecoder.cs
- Module.cs
- ListManagerBindingsCollection.cs
- unsafenativemethodstextservices.cs
- BitmapFrameDecode.cs
- EncodingTable.cs
- Publisher.cs
- embossbitmapeffect.cs
- CqlLexerHelpers.cs
- _NTAuthentication.cs
- EndpointInfoCollection.cs
- WebReferencesBuildProvider.cs
- BaseComponentEditor.cs
- CloudCollection.cs
- SystemResourceHost.cs
- ToolTip.cs
- IntranetCredentialPolicy.cs
- CodeVariableDeclarationStatement.cs
- BindingGraph.cs
- Int32AnimationBase.cs
- ResourceProviderFactory.cs
- ToolStripSystemRenderer.cs
- Crypto.cs
- MethodRental.cs
- Run.cs
- CmsInterop.cs
- KeyManager.cs