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
- StringAnimationUsingKeyFrames.cs
- CommandPlan.cs
- RelationshipDetailsCollection.cs
- Configuration.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- VirtualizingStackPanel.cs
- PropertyGridView.cs
- DirectoryRedirect.cs
- Control.cs
- MaterialCollection.cs
- DropShadowBitmapEffect.cs
- BigInt.cs
- WasEndpointConfigContainer.cs
- CursorInteropHelper.cs
- SmtpNetworkElement.cs
- WindowsListViewSubItem.cs
- ResourceIDHelper.cs
- HtmlInputControl.cs
- WorkflowServiceBehavior.cs
- EncoderParameter.cs
- MissingFieldException.cs
- DispatchWrapper.cs
- PreloadedPackages.cs
- cache.cs
- BitVec.cs
- FormViewCommandEventArgs.cs
- ToolStripManager.cs
- KeyNotFoundException.cs
- EditingCoordinator.cs
- HostingEnvironmentException.cs
- TextSpanModifier.cs
- OleDbStruct.cs
- DispatcherExceptionFilterEventArgs.cs
- TreeViewBindingsEditor.cs
- Brush.cs
- Rijndael.cs
- CornerRadius.cs
- SrgsDocumentParser.cs
- MenuEventArgs.cs
- PrintDialog.cs
- DbgCompiler.cs
- ChangesetResponse.cs
- ListItemParagraph.cs
- SqlCommand.cs
- DatagridviewDisplayedBandsData.cs
- PriorityItem.cs
- EditableLabelControl.cs
- StateMachineSubscriptionManager.cs
- SHA1.cs
- TextElementEnumerator.cs
- Label.cs
- TemplateColumn.cs
- CountAggregationOperator.cs
- CqlLexerHelpers.cs
- SynchronizationContextHelper.cs
- TextModifier.cs
- RawMouseInputReport.cs
- FacetEnabledSchemaElement.cs
- Highlights.cs
- ColumnMapVisitor.cs
- ObjectDataSourceDisposingEventArgs.cs
- MailMessageEventArgs.cs
- EntityProviderServices.cs
- ToolBar.cs
- SuppressIldasmAttribute.cs
- NativeMethods.cs
- BaseCAMarshaler.cs
- CompiledXpathExpr.cs
- ISFTagAndGuidCache.cs
- HashAlgorithm.cs
- MediaEntryAttribute.cs
- StringBlob.cs
- PolygonHotSpot.cs
- XsdDateTime.cs
- DataControlImageButton.cs
- ExpressionBindingCollection.cs
- SessionStateSection.cs
- SymbolDocumentGenerator.cs
- WorkflowTransactionOptions.cs
- Viewport2DVisual3D.cs
- PenCursorManager.cs
- KeyedCollection.cs
- SchemeSettingElement.cs
- FileDataSourceCache.cs
- ExternalFile.cs
- DataGridViewColumn.cs
- GetRecipientRequest.cs
- StylusPointDescription.cs
- TypedLocationWrapper.cs
- DataServiceBuildProvider.cs
- PhysicalOps.cs
- RedistVersionInfo.cs
- Stack.cs
- Monitor.cs
- XmlValidatingReaderImpl.cs
- DataConnectionHelper.cs
- UIAgentAsyncBeginRequest.cs
- SecurityException.cs
- Encoding.cs
- prefixendpointaddressmessagefilter.cs