Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / ndp / clr / src / BCL / System / Reflection / Pointer.cs / 1 / Pointer.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
////////////////////////////////////////////////////////////////////////////////
//
// This is a wrapper class for Pointers
//
//
//
//
namespace System.Reflection {
using System;
using CultureInfo = System.Globalization.CultureInfo;
using System.Runtime.Serialization;
[CLSCompliant(false)]
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class Pointer: ISerializable {
unsafe private void* _ptr;
private Type _ptrType;
private Pointer() {}
private unsafe Pointer(SerializationInfo info, StreamingContext context)
{
_ptr = ((IntPtr)(info.GetValue("_ptr", typeof(IntPtr)))).ToPointer();
_ptrType = (Type)info.GetValue("_ptrType", typeof(Type));
}
// This method will box an pointer. We save both the
// value and the type so we can access it from the native code
// during an Invoke.
public static unsafe Object Box(void *ptr,Type type) {
if (type == null)
throw new ArgumentNullException("type");
if (!type.IsPointer)
throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"),"ptr");
Pointer x = new Pointer();
x._ptr = ptr;
x._ptrType = type;
return x;
}
// Returned the stored pointer.
public static unsafe void* Unbox(Object ptr) {
if (!(ptr is Pointer))
throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"),"ptr");
return ((Pointer)ptr)._ptr;
}
internal Type GetPointerType() {
return _ptrType;
}
internal unsafe Object GetPointerValue() {
return (IntPtr)_ptr;
}
unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) {
info.AddValue("_ptr", new IntPtr(_ptr));
info.AddValue("_ptrType", _ptrType);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DeploymentSectionCache.cs
- sqlnorm.cs
- OutKeywords.cs
- HyperLink.cs
- PreviewKeyDownEventArgs.cs
- ControlCachePolicy.cs
- _HeaderInfo.cs
- shaperfactory.cs
- InheritanceRules.cs
- FlowDecisionLabelFeature.cs
- Serializer.cs
- XmlReaderSettings.cs
- CommandConverter.cs
- XmlNodeReader.cs
- FragmentNavigationEventArgs.cs
- ListenerUnsafeNativeMethods.cs
- ActivityDesigner.cs
- SoundPlayerAction.cs
- EntityDataSourceChangedEventArgs.cs
- COM2TypeInfoProcessor.cs
- CellIdBoolean.cs
- InstanceNormalEvent.cs
- RegexCode.cs
- XmlTextReader.cs
- QilTernary.cs
- GridViewCancelEditEventArgs.cs
- CodeDomSerializerBase.cs
- SqlMultiplexer.cs
- Char.cs
- PageRequestManager.cs
- BypassElement.cs
- Configuration.cs
- CommandLineParser.cs
- ResourceExpressionEditor.cs
- ListViewUpdatedEventArgs.cs
- CreateUserWizardDesigner.cs
- GridViewItemAutomationPeer.cs
- ContentPlaceHolder.cs
- TreeViewHitTestInfo.cs
- TreeView.cs
- DataGridViewCellCancelEventArgs.cs
- MexHttpsBindingCollectionElement.cs
- FixedSOMTable.cs
- DataSpaceManager.cs
- UnsafeNativeMethodsPenimc.cs
- QueryResponse.cs
- MouseGesture.cs
- AliasedSlot.cs
- PackagePartCollection.cs
- XPathNavigatorKeyComparer.cs
- WhiteSpaceTrimStringConverter.cs
- OracleFactory.cs
- ClockGroup.cs
- GridViewRowPresenterBase.cs
- SHA384Cng.cs
- ItemsControlAutomationPeer.cs
- WebServicesDescriptionAttribute.cs
- SelfIssuedSamlTokenFactory.cs
- Operator.cs
- HtmlSelect.cs
- WorkflowRuntime.cs
- FilterFactory.cs
- CommonObjectSecurity.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ConfigPathUtility.cs
- NativeStructs.cs
- SymmetricKeyWrap.cs
- UMPAttributes.cs
- WorkflowPersistenceContext.cs
- ListViewDeleteEventArgs.cs
- FontDriver.cs
- SortKey.cs
- MemoryStream.cs
- ThreadStaticAttribute.cs
- WebCategoryAttribute.cs
- AssertSection.cs
- CounterCreationDataCollection.cs
- BaseCAMarshaler.cs
- TypeNameConverter.cs
- WinFormsUtils.cs
- CharEnumerator.cs
- EventArgs.cs
- FastPropertyAccessor.cs
- UIElement.cs
- AssemblyAttributesGoHere.cs
- UTF7Encoding.cs
- SmtpLoginAuthenticationModule.cs
- ListParaClient.cs
- ISessionStateStore.cs
- SerTrace.cs
- Model3D.cs
- VisualBrush.cs
- XPathEmptyIterator.cs
- SessionPageStatePersister.cs
- ToolTip.cs
- ValueSerializerAttribute.cs
- OdbcReferenceCollection.cs
- XamlDesignerSerializationManager.cs
- CustomAttribute.cs
- UnsafeNativeMethods.cs