Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TransactionFlowProperty.cs / 1 / TransactionFlowProperty.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System; using System.Collections.Generic; using System.ServiceModel; using System.ServiceModel.Security; using System.Transactions; using System.Runtime.Remoting.Messaging; using System.ServiceModel.Transactions; using System.ServiceModel.Diagnostics; sealed public class TransactionMessageProperty { TransactionInfo flowedTransactionInfo; Transaction flowedTransaction; const string PropertyName = "TransactionMessageProperty"; private TransactionMessageProperty() { } public Transaction Transaction { get { if(this.flowedTransaction == null && this.flowedTransactionInfo != null) { try { this.flowedTransaction = this.flowedTransactionInfo.UnmarshalTransaction(); } catch(TransactionException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(e); } } return this.flowedTransaction; } } static internal TransactionMessageProperty TryGet(Message message) { if (message.Properties.ContainsKey(PropertyName)) return message.Properties[PropertyName] as TransactionMessageProperty; else return null; } static internal Transaction TryGetTransaction(Message message) { if (!message.Properties.ContainsKey(PropertyName)) return null; return ((TransactionMessageProperty)message.Properties[PropertyName]).Transaction; } static TransactionMessageProperty GetPropertyAndThrowIfAlreadySet(Message message) { if (message.Properties.ContainsKey(PropertyName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new FaultException(SR.GetString(SR.SFxTryAddMultipleTransactionsOnMessage))); } return new TransactionMessageProperty(); } static public void Set(Transaction transaction, Message message) { TransactionMessageProperty property = GetPropertyAndThrowIfAlreadySet(message); property.flowedTransaction = transaction; message.Properties.Add(PropertyName, property); } static internal void Set(TransactionInfo transactionInfo, Message message) { TransactionMessageProperty property = GetPropertyAndThrowIfAlreadySet(message); property.flowedTransactionInfo = transactionInfo; message.Properties.Add(PropertyName, property); } } class TransactionFlowProperty { Transaction flowedTransaction; ListissuedTokens; const string PropertyName = "TransactionFlowProperty"; private TransactionFlowProperty() { } internal ICollection IssuedTokens { get { if (this.issuedTokens == null) { this.issuedTokens = new List (); } return this.issuedTokens; } } internal Transaction Transaction { get {return this.flowedTransaction;} } static internal TransactionFlowProperty Ensure(Message message) { if (message.Properties.ContainsKey(PropertyName)) return (TransactionFlowProperty)message.Properties[PropertyName]; TransactionFlowProperty property = new TransactionFlowProperty(); message.Properties.Add(PropertyName, property); return property; } static internal TransactionFlowProperty TryGet(Message message) { if (message.Properties.ContainsKey(PropertyName)) return message.Properties[PropertyName] as TransactionFlowProperty; else return null; } static internal ICollection TryGetIssuedTokens(Message message) { TransactionFlowProperty property = TransactionFlowProperty.TryGet(message); if (property == null) return null; // use this when reading only, consistently return null if no tokens. if (property.issuedTokens == null || property.issuedTokens.Count == 0) return null; return property.issuedTokens; } static internal Transaction TryGetTransaction(Message message) { if (!message.Properties.ContainsKey(PropertyName)) return null; return ((TransactionFlowProperty)message.Properties[PropertyName]).Transaction; } static TransactionFlowProperty GetPropertyAndThrowIfAlreadySet(Message message) { TransactionFlowProperty property = TryGet(message); if (property != null) { if(property.flowedTransaction != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FaultException(SR.GetString(SR.SFxTryAddMultipleTransactionsOnMessage))); } } else { property = new TransactionFlowProperty(); } return property; } static internal void Set(Transaction transaction, Message message) { TransactionFlowProperty property = GetPropertyAndThrowIfAlreadySet(message); property.flowedTransaction = transaction; message.Properties.Add(PropertyName, property); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- LinkedResource.cs
- Helpers.cs
- Rfc4050KeyFormatter.cs
- FactorySettingsElement.cs
- ValidationHelper.cs
- UseManagedPresentationElement.cs
- ExtendedProperty.cs
- CacheAxisQuery.cs
- GraphicsState.cs
- TableCellAutomationPeer.cs
- BooleanSwitch.cs
- ExpandSegment.cs
- HandleTable.cs
- QueryCreatedEventArgs.cs
- GridItem.cs
- ContainerParagraph.cs
- compensatingcollection.cs
- SqlMethodAttribute.cs
- TextOnlyOutput.cs
- log.cs
- StoreUtilities.cs
- BindableAttribute.cs
- Vector3DKeyFrameCollection.cs
- X509CertificateValidator.cs
- ManagedWndProcTracker.cs
- AnimationStorage.cs
- Merger.cs
- OleDbPermission.cs
- ExtensionElement.cs
- XmlSchemaInferenceException.cs
- Restrictions.cs
- SiteMapNodeCollection.cs
- WorkflowServiceNamespace.cs
- ExtensionDataObject.cs
- ping.cs
- BitmapCacheBrush.cs
- DtdParser.cs
- BulletedList.cs
- SendSecurityHeaderElement.cs
- PageCodeDomTreeGenerator.cs
- OutputScopeManager.cs
- InfoCardServiceInstallComponent.cs
- SelectionProviderWrapper.cs
- XmlSerializerSection.cs
- SignHashRequest.cs
- CommandBindingCollection.cs
- MenuItemStyleCollection.cs
- FixedSOMPage.cs
- HeaderElement.cs
- ProcessHost.cs
- PriorityBindingExpression.cs
- CommandBinding.cs
- PageCodeDomTreeGenerator.cs
- RoutedEvent.cs
- ShapingWorkspace.cs
- Msec.cs
- SHA256Managed.cs
- EventLogPropertySelector.cs
- TraceHandlerErrorFormatter.cs
- PolicyVersion.cs
- Tag.cs
- HttpFormatExtensions.cs
- TypeElement.cs
- RegexWriter.cs
- DebugView.cs
- UInt16Converter.cs
- StrongNameKeyPair.cs
- Expression.cs
- SourceLineInfo.cs
- PingOptions.cs
- XmlWriter.cs
- ValueExpressions.cs
- ComEventsSink.cs
- DataGridViewCheckBoxColumn.cs
- TableParaClient.cs
- CharacterHit.cs
- WebPartZone.cs
- ValueChangedEventManager.cs
- MenuItemStyle.cs
- ThreadInterruptedException.cs
- VisualTreeUtils.cs
- _ContextAwareResult.cs
- ValueUtilsSmi.cs
- MemberDescriptor.cs
- StartFileNameEditor.cs
- ToolStripControlHost.cs
- Label.cs
- precedingquery.cs
- PeerInvitationResponse.cs
- TextContainer.cs
- Vector3DConverter.cs
- TrackingAnnotationCollection.cs
- PartitionResolver.cs
- LogoValidationException.cs
- StringToken.cs
- CompositeClientFormatter.cs
- LayoutDump.cs
- DataServiceProviderWrapper.cs
- PopupRootAutomationPeer.cs
- ExceptionUtil.cs