Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / QueueAccessMode.cs / 1305376 / QueueAccessMode.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging { using System.Diagnostics; using System; using System.Collections.Generic; using System.Messaging.Interop; ////// /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] public enum QueueAccessMode { Send = NativeMethods.QUEUE_ACCESS_SEND, Peek = NativeMethods.QUEUE_ACCESS_PEEK, Receive = NativeMethods.QUEUE_ACCESS_RECEIVE, PeekAndAdmin = NativeMethods.QUEUE_ACCESS_PEEK | NativeMethods.QUEUE_ACCESS_ADMIN, ReceiveAndAdmin = NativeMethods.QUEUE_ACCESS_RECEIVE | NativeMethods.QUEUE_ACCESS_ADMIN, /// /// SendAndReceive is supported for compatibility only. /// SendAndReceive = NativeMethods.QUEUE_ACCESS_SEND | NativeMethods.QUEUE_ACCESS_RECEIVE, } internal class QueueAccessModeHolder { private QueueAccessMode accessMode; private static Dictionary/// Specifies what operations can be performed on the queue. /// ///holders = new Dictionary () ; private QueueAccessModeHolder(QueueAccessMode accessMode) { this.accessMode = accessMode; } /// /// public static QueueAccessModeHolder GetQueueAccessModeHolder(QueueAccessMode accessMode) { if (holders.ContainsKey(accessMode)) { return holders[accessMode]; } lock (holders) { QueueAccessModeHolder newHolder = new QueueAccessModeHolder(accessMode); holders[accessMode] = newHolder; return newHolder; } } public bool CanRead() { return (((accessMode & QueueAccessMode.Receive) != 0) || ((accessMode & QueueAccessMode.Peek) != 0)); } public bool CanWrite() { return ((accessMode & QueueAccessMode.Send) != 0); } public int GetReadAccessMode() { int result = (int)(accessMode & ~QueueAccessMode.Send); if (result != 0) return result; // this is fail-fast path, when we know right away that the operation is incompatible with access mode // AccessDenied can also happen in other cases, // (for example, when we try to receive on a queue opened only for peek. // We'll let MQReceiveMessage enforce these rules throw new MessageQueueException((int)MessageQueueErrorCode.AccessDenied); } public int GetWriteAccessMode() { int result = (int)(accessMode & QueueAccessMode.Send); if (result != 0) return result; // this is fail-fast path, when we know right away that the operation is incompatible with access mode // AccessDenied can also happen in other cases, // (for example, when we try to receive on a queue opened only for peek. // We'll let MQReceiveMessage enforce these rules throw new MessageQueueException((int)MessageQueueErrorCode.AccessDenied); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007./// Factory method for getting a QueueAccessModeHolder holder. For each accessMode, we want only one holder. /// ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CommandField.cs
- DataIdProcessor.cs
- XmlEnumAttribute.cs
- ResXResourceReader.cs
- SBCSCodePageEncoding.cs
- SortDescriptionCollection.cs
- ClaimTypes.cs
- ComponentConverter.cs
- FormViewDeletedEventArgs.cs
- TraceSection.cs
- HttpConfigurationSystem.cs
- ListDictionaryInternal.cs
- MapPathBasedVirtualPathProvider.cs
- ModulesEntry.cs
- PasswordBox.cs
- _AutoWebProxyScriptHelper.cs
- StoreAnnotationsMap.cs
- TextTreeText.cs
- XmlSchemaCollection.cs
- RequestCachingSection.cs
- XmlSchemaGroup.cs
- FixedTextSelectionProcessor.cs
- ScalarType.cs
- BitmapCacheBrush.cs
- SqlClientMetaDataCollectionNames.cs
- UserInitiatedRoutedEventPermission.cs
- SQLGuidStorage.cs
- ValueSerializer.cs
- ConnectivityStatus.cs
- DataTransferEventArgs.cs
- XmlParserContext.cs
- CompletionBookmark.cs
- RC2.cs
- MergePropertyDescriptor.cs
- ExtendedPropertyDescriptor.cs
- exports.cs
- QuaternionKeyFrameCollection.cs
- DataGridViewAdvancedBorderStyle.cs
- NullableIntSumAggregationOperator.cs
- SqlDataSourceView.cs
- NamespaceQuery.cs
- AssemblyNameProxy.cs
- XmlAttributes.cs
- TransactionFormatter.cs
- XmlEnumAttribute.cs
- FormsAuthenticationConfiguration.cs
- CallbackValidatorAttribute.cs
- TimeSpanValidator.cs
- GroupItemAutomationPeer.cs
- QueryContinueDragEventArgs.cs
- DataGridViewButtonColumn.cs
- TableLayoutPanelDesigner.cs
- InfoCardCryptoHelper.cs
- PropertyDescriptor.cs
- SingleQueryOperator.cs
- HashSetEqualityComparer.cs
- Command.cs
- DeviceContexts.cs
- LocalizedNameDescriptionPair.cs
- XPathNodeList.cs
- Thread.cs
- DebugView.cs
- EventProviderWriter.cs
- XhtmlBasicListAdapter.cs
- LogLogRecordHeader.cs
- Int64KeyFrameCollection.cs
- DnsEndPoint.cs
- ServiceChannelFactory.cs
- CookielessData.cs
- TextBoxDesigner.cs
- SqlComparer.cs
- DecimalConstantAttribute.cs
- ExceptionHandlersDesigner.cs
- QilExpression.cs
- XsltArgumentList.cs
- ClientSettingsSection.cs
- SoapSchemaExporter.cs
- HMACSHA256.cs
- ExtendedTransformFactory.cs
- MetadataSerializer.cs
- DrawingImage.cs
- XmlSyndicationContent.cs
- EntityReference.cs
- ServiceCredentials.cs
- GenericWebPart.cs
- ComPlusDiagnosticTraceRecords.cs
- HttpDateParse.cs
- DynamicEntity.cs
- RegisteredScript.cs
- ReachDocumentSequenceSerializerAsync.cs
- DeviceSpecific.cs
- MetadataItemCollectionFactory.cs
- ObjectQuery_EntitySqlExtensions.cs
- PixelShader.cs
- AndCondition.cs
- EditorPartChrome.cs
- FixUp.cs
- COAUTHINFO.cs
- ServiceTimeoutsBehavior.cs
- XmlLinkedNode.cs