Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommandID.cs
- ToolBarPanel.cs
- XmlSiteMapProvider.cs
- CommandExpr.cs
- ScriptComponentDescriptor.cs
- ObfuscationAttribute.cs
- SourceFilter.cs
- DataAdapter.cs
- OutOfMemoryException.cs
- SplitContainer.cs
- PaintEvent.cs
- LayoutEngine.cs
- InputReportEventArgs.cs
- FlowDocumentScrollViewer.cs
- SigningDialog.cs
- DesignerImageAdapter.cs
- CategoryGridEntry.cs
- EmptyEnumerator.cs
- Executor.cs
- C14NUtil.cs
- IsolatedStorageSecurityState.cs
- DynamicValidatorEventArgs.cs
- cookieexception.cs
- MultiBindingExpression.cs
- CanExecuteRoutedEventArgs.cs
- FileIOPermission.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- Crc32.cs
- ProxyManager.cs
- ValidationHelper.cs
- HostingEnvironmentSection.cs
- XmlQualifiedName.cs
- ListMarkerLine.cs
- ToolStripRendererSwitcher.cs
- TableLayoutPanelCodeDomSerializer.cs
- DataSourceControlBuilder.cs
- CellTreeSimplifier.cs
- ServiceHttpModule.cs
- SystemIcmpV4Statistics.cs
- DependencyPropertyHelper.cs
- KeyValueConfigurationCollection.cs
- PropertySet.cs
- SqlDataReader.cs
- Freezable.cs
- Tablet.cs
- CodeDefaultValueExpression.cs
- DetailsViewModeEventArgs.cs
- SelectionRangeConverter.cs
- VisualStyleRenderer.cs
- OwnerDrawPropertyBag.cs
- WaitHandleCannotBeOpenedException.cs
- NativeMethods.cs
- WebPartMinimizeVerb.cs
- SqlMultiplexer.cs
- SymmetricAlgorithm.cs
- DrawTreeNodeEventArgs.cs
- MatrixAnimationBase.cs
- RecognizerBase.cs
- X509SecurityTokenProvider.cs
- EventDescriptor.cs
- CustomCredentialPolicy.cs
- LongCountAggregationOperator.cs
- NegatedCellConstant.cs
- xamlnodes.cs
- MeshGeometry3D.cs
- SqlCommandSet.cs
- SymbolType.cs
- ShimAsPublicXamlType.cs
- GeometryCombineModeValidation.cs
- Emitter.cs
- ReliableRequestSessionChannel.cs
- TextInfo.cs
- ProviderCollection.cs
- DesignerActionPropertyItem.cs
- XmlConvert.cs
- TemplateBuilder.cs
- WindowsRebar.cs
- FixedHyperLink.cs
- KeyNotFoundException.cs
- TypeReference.cs
- Behavior.cs
- ThreadPool.cs
- GridViewColumnHeaderAutomationPeer.cs
- PathData.cs
- SynchronousChannelMergeEnumerator.cs
- JsonReader.cs
- UnknownWrapper.cs
- SupportingTokenProviderSpecification.cs
- PassportAuthenticationEventArgs.cs
- ExtendedProtectionPolicyTypeConverter.cs
- InvokeAction.cs
- InteropAutomationProvider.cs
- GenericWebPart.cs
- EntityDataSourceSelectedEventArgs.cs
- MsmqAuthenticationMode.cs
- GifBitmapEncoder.cs
- VisualStyleRenderer.cs
- AdapterSwitches.cs
- StreamWithDictionary.cs
- PeerContact.cs