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
- ObjectCacheHost.cs
- NextPreviousPagerField.cs
- CodeNamespaceImportCollection.cs
- shaperfactoryquerycachekey.cs
- TextEffectResolver.cs
- Win32.cs
- PageHandlerFactory.cs
- EventProxy.cs
- Boolean.cs
- BamlLocalizabilityResolver.cs
- RichTextBoxConstants.cs
- ManagementOptions.cs
- MissingSatelliteAssemblyException.cs
- XmlBufferReader.cs
- CharAnimationBase.cs
- DeploymentSection.cs
- SmiContextFactory.cs
- CommandLibraryHelper.cs
- XmlNamespaceManager.cs
- ExtendedPropertiesHandler.cs
- DataPagerCommandEventArgs.cs
- PersianCalendar.cs
- ByValueEqualityComparer.cs
- ContainerFilterService.cs
- MouseActionValueSerializer.cs
- MultiBindingExpression.cs
- SoapFormatterSinks.cs
- ProxyElement.cs
- WebPart.cs
- TaiwanCalendar.cs
- OutputCacheProfileCollection.cs
- ImageKeyConverter.cs
- DesignerOptionService.cs
- ListViewItem.cs
- StatusBarPanel.cs
- RootAction.cs
- WindowsClientCredential.cs
- ProfessionalColorTable.cs
- DiscardableAttribute.cs
- DocumentViewerBaseAutomationPeer.cs
- XmlKeywords.cs
- TreeNodeCollection.cs
- RenderingEventArgs.cs
- CodePrimitiveExpression.cs
- DataGridCheckBoxColumn.cs
- DataBoundControlAdapter.cs
- LogExtent.cs
- ElementProxy.cs
- DesignerObjectListAdapter.cs
- SmtpClient.cs
- BitmapScalingModeValidation.cs
- ReverseInheritProperty.cs
- BufferedGraphics.cs
- FixedSOMPageElement.cs
- MatrixTransform3D.cs
- SolidBrush.cs
- TableSectionStyle.cs
- SHA384.cs
- DataException.cs
- BaseTemplateBuildProvider.cs
- EncodingInfo.cs
- PolicyManager.cs
- TripleDESCryptoServiceProvider.cs
- SolidColorBrush.cs
- HelpInfo.cs
- util.cs
- AssemblyAssociatedContentFileAttribute.cs
- ErrorWebPart.cs
- MarginCollapsingState.cs
- _UncName.cs
- FilterException.cs
- PersonalizableTypeEntry.cs
- ContextMarshalException.cs
- Timer.cs
- MenuItemBinding.cs
- AudioException.cs
- ThousandthOfEmRealPoints.cs
- TableStyle.cs
- DataServiceContext.cs
- XmlException.cs
- BaseResourcesBuildProvider.cs
- TreeViewHitTestInfo.cs
- XmlAttributeAttribute.cs
- RenderTargetBitmap.cs
- EmptyImpersonationContext.cs
- MarginCollapsingState.cs
- BitmapEffectGroup.cs
- HebrewCalendar.cs
- ObjectCloneHelper.cs
- CLRBindingWorker.cs
- ControlIdConverter.cs
- DataControlFieldCell.cs
- ReceiveSecurityHeader.cs
- CapabilitiesRule.cs
- WindowsPen.cs
- ModuleBuilderData.cs
- OwnerDrawPropertyBag.cs
- MarginCollapsingState.cs
- TextSchema.cs
- StaticExtensionConverter.cs