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
- EntityViewGenerator.cs
- WebSysDefaultValueAttribute.cs
- GetPageCompletedEventArgs.cs
- DataGridColumnCollectionEditor.cs
- CharacterString.cs
- CryptoKeySecurity.cs
- URLAttribute.cs
- _SslStream.cs
- CompiledXpathExpr.cs
- WpfGeneratedKnownTypes.cs
- PrivilegedConfigurationManager.cs
- DataServiceQueryOfT.cs
- DataGridViewRowCancelEventArgs.cs
- SchemaEntity.cs
- HitTestFilterBehavior.cs
- RotateTransform.cs
- ModifierKeysValueSerializer.cs
- FileNameEditor.cs
- Variable.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- ButtonBaseAutomationPeer.cs
- RectKeyFrameCollection.cs
- PerfCounterSection.cs
- LineProperties.cs
- InfoCardBaseException.cs
- SettingsProviderCollection.cs
- ActionFrame.cs
- ReleaseInstanceMode.cs
- RelationshipConverter.cs
- StorageScalarPropertyMapping.cs
- ConnectionStringsExpressionBuilder.cs
- SharedDp.cs
- PropertyMetadata.cs
- AnimationException.cs
- TagPrefixCollection.cs
- DateTimeOffset.cs
- _ConnectionGroup.cs
- OperationAbortedException.cs
- Serializer.cs
- Rect3DValueSerializer.cs
- ComponentSerializationService.cs
- DynamicPhysicalDiscoSearcher.cs
- RMPublishingDialog.cs
- FileLoadException.cs
- DirectoryGroupQuery.cs
- XmlTextAttribute.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- OpacityConverter.cs
- PageEventArgs.cs
- UserControlCodeDomTreeGenerator.cs
- CoordinationService.cs
- ClientSponsor.cs
- NgenServicingAttributes.cs
- EnterpriseServicesHelper.cs
- PeerApplicationLaunchInfo.cs
- QilCloneVisitor.cs
- CaretElement.cs
- BlurBitmapEffect.cs
- ThicknessAnimation.cs
- DataSourceControl.cs
- ListItemsCollectionEditor.cs
- FixedPageProcessor.cs
- StylusTip.cs
- GradientStop.cs
- Assert.cs
- ISAPIWorkerRequest.cs
- DebugView.cs
- safex509handles.cs
- DbFunctionCommandTree.cs
- CallId.cs
- SequentialWorkflowRootDesigner.cs
- PerfService.cs
- __Error.cs
- SByteStorage.cs
- VariableElement.cs
- RichTextBox.cs
- CodeCompiler.cs
- CodeEntryPointMethod.cs
- IfAction.cs
- GradientBrush.cs
- DataChangedEventManager.cs
- XmlNodeChangedEventManager.cs
- CellTreeNodeVisitors.cs
- QueryAccessibilityHelpEvent.cs
- StatusStrip.cs
- ColumnWidthChangedEvent.cs
- List.cs
- ClientConfigPaths.cs
- PagePropertiesChangingEventArgs.cs
- MemberRelationshipService.cs
- XmlSchemaInclude.cs
- AvTraceFormat.cs
- ScriptModule.cs
- ToggleButtonAutomationPeer.cs
- ListViewGroupConverter.cs
- versioninfo.cs
- RefreshPropertiesAttribute.cs
- AuthorizationSection.cs
- ServiceDocumentFormatter.cs
- CellParagraph.cs