Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / MsmqBindingElementBase.cs / 1 / MsmqBindingElementBase.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Net.Security; using System.ServiceModel.Description; using System.Runtime.Serialization; using System.ServiceModel; using System.Collections.Generic; using System.ServiceModel.Security; using System.Xml; public abstract class MsmqBindingElementBase : TransportBindingElement, ITransactedBindingElement, IWsdlExportExtension, IPolicyExportExtension, ITransportPolicyImport { Uri customDeadLetterQueue; DeadLetterQueue deadLetterQueue; bool durable; bool exactlyOnce; int maxRetryCycles; ReceiveErrorHandling receiveErrorHandling; int receiveRetryCount; TimeSpan retryCycleDelay; TimeSpan timeToLive; MsmqTransportSecurity msmqTransportSecurity; bool useMsmqTracing; bool useSourceJournal; internal MsmqBindingElementBase() { this.customDeadLetterQueue = MsmqDefaults.CustomDeadLetterQueue; this.deadLetterQueue = MsmqDefaults.DeadLetterQueue; this.durable = MsmqDefaults.Durable; this.exactlyOnce = MsmqDefaults.ExactlyOnce; this.maxRetryCycles = MsmqDefaults.MaxRetryCycles; this.receiveErrorHandling = MsmqDefaults.ReceiveErrorHandling; this.receiveRetryCount = MsmqDefaults.ReceiveRetryCount; this.retryCycleDelay = MsmqDefaults.RetryCycleDelay; this.timeToLive = MsmqDefaults.TimeToLive; this.msmqTransportSecurity = new MsmqTransportSecurity(); this.useMsmqTracing = MsmqDefaults.UseMsmqTracing; this.useSourceJournal = MsmqDefaults.UseSourceJournal; } internal MsmqBindingElementBase(MsmqBindingElementBase elementToBeCloned) : base(elementToBeCloned) { this.customDeadLetterQueue = elementToBeCloned.customDeadLetterQueue; this.deadLetterQueue = elementToBeCloned.deadLetterQueue; this.durable = elementToBeCloned.durable; this.exactlyOnce = elementToBeCloned.exactlyOnce; this.maxRetryCycles = elementToBeCloned.maxRetryCycles; this.msmqTransportSecurity = new MsmqTransportSecurity(elementToBeCloned.MsmqTransportSecurity); this.receiveErrorHandling = elementToBeCloned.receiveErrorHandling; this.receiveRetryCount = elementToBeCloned.receiveRetryCount; this.retryCycleDelay = elementToBeCloned.retryCycleDelay; this.timeToLive = elementToBeCloned.timeToLive; this.useMsmqTracing = elementToBeCloned.useMsmqTracing; this.useSourceJournal = elementToBeCloned.useSourceJournal; } internal abstract MsmqUri.IAddressTranslator AddressTranslator { get; } // applicable on: client public Uri CustomDeadLetterQueue { get { return this.customDeadLetterQueue; } set { this.customDeadLetterQueue = value; } } // applicable on: client public DeadLetterQueue DeadLetterQueue { get { return this.deadLetterQueue; } set { if (! DeadLetterQueueHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.deadLetterQueue = value; } } // applicable on: client public bool Durable { get { return this.durable; } set { this.durable = value; } } public bool TransactedReceiveEnabled { get { return this.exactlyOnce; } } // applicable on: client, server public bool ExactlyOnce { get { return this.exactlyOnce; } set { this.exactlyOnce = value; } } // applicable on: server public int ReceiveRetryCount { get { return this.receiveRetryCount; } set { if (value < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("value", value, SR.GetString(SR.MsmqNonNegativeArgumentExpected))); } this.receiveRetryCount = value; } } // applicable on: server public int MaxRetryCycles { get { return this.maxRetryCycles; } set { if (value < 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("value", value, SR.GetString(SR.MsmqNonNegativeArgumentExpected))); } this.maxRetryCycles = value; } } // applicable on: client, server public MsmqTransportSecurity MsmqTransportSecurity { get { return this.msmqTransportSecurity; } internal set { this.msmqTransportSecurity = value; } } // applicable on: server public ReceiveErrorHandling ReceiveErrorHandling { get { return this.receiveErrorHandling; } set { if (! ReceiveErrorHandlingHelper.IsDefined(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value")); } this.receiveErrorHandling = value; } } // applicable on: server public TimeSpan RetryCycleDelay { get { return this.retryCycleDelay; } set { if (value < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value, SR.GetString(SR.SFxTimeoutOutOfRange0))); } if (TimeoutHelper.IsTooLarge(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value, SR.GetString(SR.SFxTimeoutOutOfRangeTooBig))); } this.retryCycleDelay = value; } } // applicable on: client public TimeSpan TimeToLive { get { return this.timeToLive; } set { if (value < TimeSpan.Zero) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value, SR.GetString(SR.SFxTimeoutOutOfRange0))); } if (TimeoutHelper.IsTooLarge(value)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", value, SR.GetString(SR.SFxTimeoutOutOfRangeTooBig))); } this.timeToLive = value; } } public bool UseMsmqTracing { get { return this.useMsmqTracing; } set { this.useMsmqTracing = value; } } public bool UseSourceJournal { get { return this.useSourceJournal; } set { this.useSourceJournal = value; } } public override T GetProperty(BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (typeof(T) == typeof(ISecurityCapabilities)) { return null; } else if (typeof(T) == typeof(IBindingDeliveryCapabilities)) { return (T)(object)new BindingDeliveryCapabilitiesHelper(); } else { return base.GetProperty (context); } } static bool FindAssertion(ICollection assertions, string name) { return (PolicyConversionContext.FindAssertion(assertions, name, TransportPolicyConstants.MsmqTransportNamespace, true) != null); } void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { if (exporter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exporter"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } XmlDocument document = new XmlDocument(); ICollection policyAssertions = context.GetBindingAssertions(); if (!this.Durable) { policyAssertions.Add(document.CreateElement( TransportPolicyConstants.MsmqTransportPrefix, TransportPolicyConstants.MsmqVolatile, TransportPolicyConstants.MsmqTransportNamespace)); } if (!this.ExactlyOnce) { policyAssertions.Add(document.CreateElement( TransportPolicyConstants.MsmqTransportPrefix, TransportPolicyConstants.MsmqBestEffort, TransportPolicyConstants.MsmqTransportNamespace)); } if (context.Contract.SessionMode == SessionMode.Required) { policyAssertions.Add(document.CreateElement( TransportPolicyConstants.MsmqTransportPrefix, TransportPolicyConstants.MsmqSession, TransportPolicyConstants.MsmqTransportNamespace)); } if (this.MsmqTransportSecurity.MsmqProtectionLevel != ProtectionLevel.None) { policyAssertions.Add(document.CreateElement( TransportPolicyConstants.MsmqTransportPrefix, TransportPolicyConstants.MsmqAuthenticated, TransportPolicyConstants.MsmqTransportNamespace)); if (this.MsmqTransportSecurity.MsmqAuthenticationMode == MsmqAuthenticationMode.WindowsDomain) { policyAssertions.Add(document.CreateElement( TransportPolicyConstants.MsmqTransportPrefix, TransportPolicyConstants.MsmqWindowsDomain, TransportPolicyConstants.MsmqTransportNamespace)); } } bool createdNew; MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(context.BindingElements, out createdNew); if (createdNew && encodingBindingElement is IPolicyExportExtension) { ((IPolicyExportExtension)encodingBindingElement).ExportPolicy(exporter, context); } WsdlExporter.WSAddressingHelper.AddWSAddressingAssertion(exporter, context, encodingBindingElement.MessageVersion.Addressing); } void ITransportPolicyImport.ImportPolicy(MetadataImporter importer, PolicyConversionContext policyContext) { ICollection policyAssertions = policyContext.GetBindingAssertions(); if (FindAssertion(policyAssertions, TransportPolicyConstants.MsmqVolatile)) { this.Durable = false; } if (FindAssertion(policyAssertions, TransportPolicyConstants.MsmqBestEffort)) { this.ExactlyOnce = false; } if (FindAssertion(policyAssertions, TransportPolicyConstants.MsmqSession)) { policyContext.Contract.SessionMode = SessionMode.Required; } if (FindAssertion(policyAssertions, TransportPolicyConstants.MsmqAuthenticated)) { this.MsmqTransportSecurity.MsmqProtectionLevel = ProtectionLevel.Sign; if (FindAssertion(policyAssertions, TransportPolicyConstants.MsmqWindowsDomain)) this.MsmqTransportSecurity.MsmqAuthenticationMode = MsmqAuthenticationMode.WindowsDomain; else this.MsmqTransportSecurity.MsmqAuthenticationMode = MsmqAuthenticationMode.Certificate; } else { this.MsmqTransportSecurity.MsmqProtectionLevel = ProtectionLevel.None; this.MsmqTransportSecurity.MsmqAuthenticationMode = MsmqAuthenticationMode.None; } } void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context) { } internal virtual string WsdlTransportUri { get { return null; } } void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext) { bool createdNew; MessageEncodingBindingElement encodingBindingElement = FindMessageEncodingBindingElement(endpointContext, out createdNew); TransportBindingElement.ExportWsdlEndpoint( exporter, endpointContext, this.WsdlTransportUri, encodingBindingElement.MessageVersion.Addressing); } MessageEncodingBindingElement FindMessageEncodingBindingElement(BindingElementCollection bindingElements, out bool createdNew) { createdNew = false; MessageEncodingBindingElement encodingBindingElement = bindingElements.Find (); if (encodingBindingElement == null) { createdNew = true; encodingBindingElement = new BinaryMessageEncodingBindingElement(); } return encodingBindingElement; } MessageEncodingBindingElement FindMessageEncodingBindingElement(WsdlEndpointConversionContext endpointContext, out bool createdNew) { BindingElementCollection bindingElements = endpointContext.Endpoint.Binding.CreateBindingElements(); return FindMessageEncodingBindingElement(bindingElements, out createdNew); } class BindingDeliveryCapabilitiesHelper : IBindingDeliveryCapabilities { internal BindingDeliveryCapabilitiesHelper() { } bool IBindingDeliveryCapabilities.AssuresOrderedDelivery { get { return false; } } bool IBindingDeliveryCapabilities.QueuedDelivery { get { return true; } } } } } // 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
- IInstanceTable.cs
- StubHelpers.cs
- DbCommandDefinition.cs
- StateChangeEvent.cs
- Rfc2898DeriveBytes.cs
- NotImplementedException.cs
- SelectionRange.cs
- WebPartAuthorizationEventArgs.cs
- ParameterDataSourceExpression.cs
- PeerCollaboration.cs
- UIAgentCrashedException.cs
- HtmlShimManager.cs
- ItemType.cs
- ExtendedPropertyDescriptor.cs
- XmlEnumAttribute.cs
- ProfileServiceManager.cs
- SerializationInfoEnumerator.cs
- ThicknessConverter.cs
- TransformerInfo.cs
- ImportFileRequest.cs
- EntryPointNotFoundException.cs
- XPathNavigatorKeyComparer.cs
- XsltArgumentList.cs
- nulltextcontainer.cs
- FilterException.cs
- SerializationSectionGroup.cs
- NavigationHelper.cs
- Lazy.cs
- StorageEntitySetMapping.cs
- BeginGetFileNameFromUserRequest.cs
- ListControl.cs
- DrawingContextWalker.cs
- PropertyIDSet.cs
- DynamicMetaObjectBinder.cs
- WebServiceClientProxyGenerator.cs
- DbConnectionStringCommon.cs
- ZoneLinkButton.cs
- serverconfig.cs
- Rotation3DAnimation.cs
- HyperLinkColumn.cs
- WindowsFormsHelpers.cs
- Grid.cs
- COM2IProvidePropertyBuilderHandler.cs
- Context.cs
- ExpressionBinding.cs
- UntypedNullExpression.cs
- RepeatButtonAutomationPeer.cs
- PeerService.cs
- CacheChildrenQuery.cs
- OdbcDataAdapter.cs
- PlainXmlSerializer.cs
- XmlSchemaDatatype.cs
- MetadataWorkspace.cs
- InstanceData.cs
- ClientRolePrincipal.cs
- SpellerStatusTable.cs
- AlternateViewCollection.cs
- MailAddressCollection.cs
- RSAPKCS1SignatureFormatter.cs
- CompositeControlDesigner.cs
- ServiceConfigurationTraceRecord.cs
- codemethodreferenceexpression.cs
- ColumnResizeAdorner.cs
- XsltLoader.cs
- LoadItemsEventArgs.cs
- LOSFormatter.cs
- Win32KeyboardDevice.cs
- Stopwatch.cs
- __FastResourceComparer.cs
- DocumentSchemaValidator.cs
- ArraySegment.cs
- DigitalSignature.cs
- ScriptResourceMapping.cs
- StateManagedCollection.cs
- XmlHierarchicalDataSourceView.cs
- ObjectStateFormatter.cs
- OutputScope.cs
- XXXInfos.cs
- RelationshipType.cs
- TrustSection.cs
- SmtpReplyReader.cs
- Substitution.cs
- BindingMemberInfo.cs
- ScrollContentPresenter.cs
- SoapServerProtocol.cs
- Button.cs
- Closure.cs
- Model3DGroup.cs
- TableLayoutStyleCollection.cs
- SqlParameter.cs
- PersistenceTypeAttribute.cs
- AuthenticationModuleElement.cs
- CAGDesigner.cs
- EventProviderWriter.cs
- OpenFileDialog.cs
- QueryOutputWriter.cs
- GridViewCommandEventArgs.cs
- BuildResult.cs
- StylusSystemGestureEventArgs.cs
- QfeChecker.cs