Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / Interop / SafeHandles.cs / 1305376 / SafeHandles.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging.Interop { using System; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; internal class MessageQueueHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly MessageQueueHandle InvalidHandle = new InvalidMessageQueueHandle(); MessageQueueHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseQueue(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidMessageQueueHandle : MessageQueueHandle { protected override bool ReleaseHandle() { return true; } } } internal class CursorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly CursorHandle NullHandle = new InvalidCursorHandle(); protected CursorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseCursor(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidCursorHandle : CursorHandle { protected override bool ReleaseHandle() { return true; } } } internal class LocatorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly LocatorHandle InvalidHandle = new InvalidLocatorHandle(); protected LocatorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQLocateEnd(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidLocatorHandle : LocatorHandle { protected override bool ReleaseHandle() { return true; } } } internal sealed class SecurityContextHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SecurityContextHandle(IntPtr existingHandle) : base(true) { SetHandle(existingHandle); } protected override bool ReleaseHandle() { SafeNativeMethods.MQFreeSecurityContext(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging.Interop { using System; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; internal class MessageQueueHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly MessageQueueHandle InvalidHandle = new InvalidMessageQueueHandle(); MessageQueueHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseQueue(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidMessageQueueHandle : MessageQueueHandle { protected override bool ReleaseHandle() { return true; } } } internal class CursorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly CursorHandle NullHandle = new InvalidCursorHandle(); protected CursorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseCursor(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidCursorHandle : CursorHandle { protected override bool ReleaseHandle() { return true; } } } internal class LocatorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly LocatorHandle InvalidHandle = new InvalidLocatorHandle(); protected LocatorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQLocateEnd(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidLocatorHandle : LocatorHandle { protected override bool ReleaseHandle() { return true; } } } internal sealed class SecurityContextHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SecurityContextHandle(IntPtr existingHandle) : base(true) { SetHandle(existingHandle); } protected override bool ReleaseHandle() { SafeNativeMethods.MQFreeSecurityContext(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } } } // 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
- Int16.cs
- DataConnectionHelper.cs
- ModuleElement.cs
- ExecutionEngineException.cs
- XPathConvert.cs
- _ProxyChain.cs
- ItemDragEvent.cs
- XmlBufferReader.cs
- CachedFontFace.cs
- OdbcTransaction.cs
- TextChange.cs
- SafeUserTokenHandle.cs
- HttpSocketManager.cs
- MenuItemBinding.cs
- AppliedDeviceFiltersEditor.cs
- Simplifier.cs
- EntityKey.cs
- CompoundFileIOPermission.cs
- CompilerScope.Storage.cs
- DiscoveryReferences.cs
- Misc.cs
- Exceptions.cs
- WeakEventManager.cs
- SmiRecordBuffer.cs
- DataGridViewCellValueEventArgs.cs
- StatementContext.cs
- RtfToXamlLexer.cs
- KeySplineConverter.cs
- LogicalTreeHelper.cs
- DataGridViewAccessibleObject.cs
- ItemCheckedEvent.cs
- HwndSource.cs
- Timer.cs
- Misc.cs
- NotCondition.cs
- unitconverter.cs
- XmlTypeAttribute.cs
- RegexCapture.cs
- FreezableCollection.cs
- Drawing.cs
- LabelAutomationPeer.cs
- Column.cs
- XPathDocumentBuilder.cs
- FormsAuthenticationTicket.cs
- WinEventQueueItem.cs
- WebPartZoneBase.cs
- FontStretches.cs
- StateDesigner.LayoutSelectionGlyph.cs
- DataFieldConverter.cs
- SqlProvider.cs
- TabControlEvent.cs
- ScriptManagerProxy.cs
- X509ImageLogo.cs
- Interop.cs
- ProviderConnectionPointCollection.cs
- CurrentChangingEventManager.cs
- WebColorConverter.cs
- ItemMap.cs
- ScrollPatternIdentifiers.cs
- PathFigureCollectionConverter.cs
- DesignerCalendarAdapter.cs
- FixedSOMTableRow.cs
- ScrollBar.cs
- DataSourceView.cs
- LineBreakRecord.cs
- SettingsBase.cs
- DataGridViewBand.cs
- WindowsListViewScroll.cs
- PresentationAppDomainManager.cs
- IntSecurity.cs
- SharedRuntimeState.cs
- EventBuilder.cs
- TextCharacters.cs
- xdrvalidator.cs
- GraphicsContext.cs
- CountdownEvent.cs
- RadioButtonAutomationPeer.cs
- TableAdapterManagerHelper.cs
- ResourceIDHelper.cs
- DesignerVerbCollection.cs
- ThreadInterruptedException.cs
- StaticFileHandler.cs
- XmlSchemaSearchPattern.cs
- SpecialNameAttribute.cs
- RadioButtonFlatAdapter.cs
- StringValidatorAttribute.cs
- ZipPackagePart.cs
- SplineQuaternionKeyFrame.cs
- DocumentGridContextMenu.cs
- Oid.cs
- WebSysDisplayNameAttribute.cs
- SurrogateChar.cs
- StylusPlugInCollection.cs
- DateTimeFormat.cs
- DataGridColumnHeadersPresenterAutomationPeer.cs
- DecimalAnimation.cs
- AsyncOperationManager.cs
- XamlInterfaces.cs
- DocumentEventArgs.cs
- MediaContext.cs