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
- ViewBox.cs
- WindowsImpersonationContext.cs
- EntityDataSource.cs
- SineEase.cs
- TemplateControl.cs
- ByteConverter.cs
- QueryContext.cs
- PropertyGridView.cs
- StrokeCollectionConverter.cs
- BitmapSource.cs
- SiteMapPath.cs
- MouseGestureValueSerializer.cs
- DbProviderConfigurationHandler.cs
- ResumeStoryboard.cs
- SubMenuStyle.cs
- SerializationException.cs
- DataBindingHandlerAttribute.cs
- SyntaxCheck.cs
- TypeBuilder.cs
- HtmlInputReset.cs
- RegexGroup.cs
- FormView.cs
- WebPartChrome.cs
- xamlnodes.cs
- XPathParser.cs
- UInt32.cs
- UpdatePanelControlTrigger.cs
- BamlRecordHelper.cs
- AddInStore.cs
- Schema.cs
- XmlSerializationWriter.cs
- ExtendedPropertyCollection.cs
- Inline.cs
- XPathNode.cs
- RSAPKCS1SignatureDeformatter.cs
- CacheMode.cs
- ContainerControl.cs
- CompositeFontFamily.cs
- DropDownButton.cs
- ListControlDataBindingHandler.cs
- SmtpMail.cs
- JulianCalendar.cs
- ResourceContainer.cs
- XmlSerializerFactory.cs
- PageParserFilter.cs
- PolygonHotSpot.cs
- BoundsDrawingContextWalker.cs
- ArrayItemValue.cs
- SafeFileMappingHandle.cs
- BamlBinaryReader.cs
- ListControlConvertEventArgs.cs
- TreeViewDesigner.cs
- OdbcParameter.cs
- CodeGenerator.cs
- _HeaderInfoTable.cs
- SynchronizationContext.cs
- XmlNotation.cs
- RequestCacheValidator.cs
- GridViewUpdatedEventArgs.cs
- DataControlHelper.cs
- SqlDataSourceCommandEventArgs.cs
- GridItemProviderWrapper.cs
- ManipulationStartedEventArgs.cs
- RevocationPoint.cs
- PackagingUtilities.cs
- HTTPNotFoundHandler.cs
- MouseDevice.cs
- Int32Converter.cs
- StrokeCollectionConverter.cs
- initElementDictionary.cs
- ExpandSegment.cs
- DockProviderWrapper.cs
- MailMessageEventArgs.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- LineVisual.cs
- MediaPlayerState.cs
- ProviderMetadataCachedInformation.cs
- sqlstateclientmanager.cs
- AnnotationAdorner.cs
- ResourceProviderFactory.cs
- localization.cs
- HttpProtocolReflector.cs
- iisPickupDirectory.cs
- ArraySegment.cs
- DataGridViewRowCancelEventArgs.cs
- Stream.cs
- Positioning.cs
- NativeObjectSecurity.cs
- SpecularMaterial.cs
- TopClause.cs
- FileRecordSequence.cs
- DbConnectionFactory.cs
- ApplicationSettingsBase.cs
- _BaseOverlappedAsyncResult.cs
- CollectionChange.cs
- VisualStyleElement.cs
- ConfigurationValue.cs
- Line.cs
- GridViewRowEventArgs.cs
- ValidationErrorCollection.cs