Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / CompositeDuplexBindingElement.cs / 1 / CompositeDuplexBindingElement.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.ServiceModel; using System.Runtime.Serialization; using System.Xml; using System.ServiceModel.Description; using System.ServiceModel.Security; public sealed class CompositeDuplexBindingElement : BindingElement, IPolicyExportExtension { Uri clientBaseAddress; public CompositeDuplexBindingElement() { } CompositeDuplexBindingElement(CompositeDuplexBindingElement elementToBeCloned) : base(elementToBeCloned) { this.clientBaseAddress = elementToBeCloned.ClientBaseAddress; } public Uri ClientBaseAddress { get { return this.clientBaseAddress; } set { this.clientBaseAddress = value; } } public override BindingElement Clone() { return new CompositeDuplexBindingElement(this); } public override IChannelFactoryBuildChannelFactory (BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (typeof(TChannel) != typeof(IOutputChannel)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel))); } return context.BuildInnerChannelFactory (); } public override IChannelListener BuildChannelListener (BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (typeof(TChannel) != typeof(IInputChannel)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel))); } if (context.ListenUriBaseAddress == null) { if (this.clientBaseAddress != null) { context.ListenUriBaseAddress = this.clientBaseAddress; context.ListenUriRelativeAddress = Guid.NewGuid().ToString(); context.ListenUriMode = ListenUriMode.Explicit; } else { // #pragma warning suppress 56506 // [....], context.Binding will never be null. context.ListenUriRelativeAddress = String.Empty; context.ListenUriMode = ListenUriMode.Unique; } } return context.BuildInnerChannelListener (); } public override bool CanBuildChannelFactory (BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } return (typeof(TChannel) == typeof(IOutputChannel)) && context.CanBuildInnerChannelFactory (); } public override bool CanBuildChannelListener (BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } return (typeof(TChannel) == typeof(IInputChannel)) && context.CanBuildInnerChannelListener (); } ChannelProtectionRequirements GetProtectionRequirements() { ChannelProtectionRequirements result = new ChannelProtectionRequirements(); XmlQualifiedName refPropHeaderName = new XmlQualifiedName(XD.UtilityDictionary.UniqueEndpointHeaderName.Value, XD.UtilityDictionary.UniqueEndpointHeaderNamespace.Value); MessagePartSpecification headerParts = new MessagePartSpecification(refPropHeaderName); headerParts.MakeReadOnly(); result.IncomingSignatureParts.AddParts(headerParts); result.OutgoingSignatureParts.AddParts(headerParts); return result; } public override T GetProperty (BindingContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (typeof(T) == typeof(ISecurityCapabilities)) { ISecurityCapabilities lowerCapabilities = context.GetInnerProperty (); if (lowerCapabilities != null) { // composite duplex cannot ensure that messages it receives are from the part it sends // messages to. So it cannot offer server auth return (T) (object)(new SecurityCapabilities(lowerCapabilities.SupportsClientAuthentication, false, lowerCapabilities.SupportsClientWindowsIdentity, lowerCapabilities.SupportedRequestProtectionLevel, System.Net.Security.ProtectionLevel.None)); } else { return null; } } else if (typeof(T) == typeof(ChannelProtectionRequirements)) { ChannelProtectionRequirements myRequirements = this.GetProtectionRequirements(); myRequirements.Add(context.GetInnerProperty () ?? new ChannelProtectionRequirements()); return (T)(object)myRequirements; } else { return context.GetInnerProperty (); } } internal override bool IsMatch(BindingElement b) { if (b == null) { return false; } CompositeDuplexBindingElement duplex = b as CompositeDuplexBindingElement; if (duplex == null) { return false; } return (this.clientBaseAddress == duplex.clientBaseAddress); } void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { if (context == null) throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); exporter.State[typeof(SupportedAddressingMode).Name] = SupportedAddressingMode.NonAnonymous; context.GetBindingAssertions().Add(CreateCompositeDuplexAssertion()); } static XmlElement CreateCompositeDuplexAssertion() { XmlDocument doc = new XmlDocument(); return doc.CreateElement(TransportPolicyConstants.CompositeDuplexPrefix, TransportPolicyConstants.CompositeDuplex, TransportPolicyConstants.CompositeDuplexNamespace); } } } // 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
- SystemUnicastIPAddressInformation.cs
- PeerNameResolver.cs
- HtmlFormAdapter.cs
- SoapFault.cs
- QilParameter.cs
- CompilationSection.cs
- CombinedTcpChannel.cs
- BlockUIContainer.cs
- XmlElementAttribute.cs
- NativeMethods.cs
- LocalBuilder.cs
- ButtonBase.cs
- ThumbButtonInfo.cs
- ChildChangedEventArgs.cs
- QilInvoke.cs
- DataBoundControlParameterTarget.cs
- odbcmetadatafactory.cs
- SwitchElementsCollection.cs
- DragCompletedEventArgs.cs
- TextFormatterImp.cs
- InfoCardTraceRecord.cs
- ActivityStateQuery.cs
- ResourceProviderFactory.cs
- TextSpanModifier.cs
- WebWorkflowRole.cs
- MainMenu.cs
- ManualResetEventSlim.cs
- CopyAttributesAction.cs
- SoapSchemaExporter.cs
- Int32CollectionConverter.cs
- Encoder.cs
- ModuleConfigurationInfo.cs
- UrlUtility.cs
- CacheOutputQuery.cs
- RootProjectionNode.cs
- BamlTreeUpdater.cs
- FieldNameLookup.cs
- BitmapInitialize.cs
- Trustee.cs
- EntityAdapter.cs
- DigitalSignature.cs
- SecuritySessionClientSettings.cs
- DSASignatureDeformatter.cs
- StringArrayConverter.cs
- EnumValAlphaComparer.cs
- RecommendedAsConfigurableAttribute.cs
- Activator.cs
- DataColumnChangeEvent.cs
- EventlogProvider.cs
- AnnotationMap.cs
- SinglePhaseEnlistment.cs
- Context.cs
- ButtonBase.cs
- TabControlAutomationPeer.cs
- WindowsClientCredential.cs
- FlowchartDesigner.Helpers.cs
- StatusBarPanelClickEvent.cs
- SpellCheck.cs
- AssemblyUtil.cs
- LookupBindingPropertiesAttribute.cs
- ServerIdentity.cs
- SmiEventSink_Default.cs
- Array.cs
- AutomationElement.cs
- StickyNote.cs
- WorkflowRuntimeSection.cs
- Subset.cs
- Debug.cs
- WebPartUserCapability.cs
- DispatcherSynchronizationContext.cs
- DataGridViewRowsAddedEventArgs.cs
- SoapSchemaExporter.cs
- Ipv6Element.cs
- DesignerUtility.cs
- RegexBoyerMoore.cs
- OneWayBindingElementImporter.cs
- PeerInvitationResponse.cs
- Rijndael.cs
- DebugView.cs
- ObjectAssociationEndMapping.cs
- RenderingBiasValidation.cs
- GeneralTransform3DGroup.cs
- PixelFormat.cs
- GetPageNumberCompletedEventArgs.cs
- VectorAnimationBase.cs
- DynamicRenderer.cs
- CompatibleComparer.cs
- DecoderBestFitFallback.cs
- LookupBindingPropertiesAttribute.cs
- MappedMetaModel.cs
- PolyBezierSegment.cs
- ContextMenuStripGroupCollection.cs
- GenerateScriptTypeAttribute.cs
- DataSourceXmlSerializer.cs
- DecoderReplacementFallback.cs
- MemberAccessException.cs
- ItemCollection.cs
- UIElementParagraph.cs
- SetterBaseCollection.cs
- XDeferredAxisSource.cs