Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / InternalDuplexBindingElement.cs / 1 / InternalDuplexBindingElement.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
using System.ServiceModel.Security;
using System.ServiceModel.Dispatcher;
sealed class InternalDuplexBindingElement : BindingElement
{
InputChannelDemuxer clientChannelDemuxer;
bool providesCorrelation;
public InternalDuplexBindingElement()
: this(false)
{
}
//
internal InternalDuplexBindingElement(bool providesCorrelation)
: base()
{
this.providesCorrelation = providesCorrelation;
}
InternalDuplexBindingElement(InternalDuplexBindingElement elementToBeCloned)
: base(elementToBeCloned)
{
this.clientChannelDemuxer = elementToBeCloned.ClientChannelDemuxer;
this.providesCorrelation = elementToBeCloned.ProvidesCorrelation;
}
internal InputChannelDemuxer ClientChannelDemuxer
{
get { return this.clientChannelDemuxer; }
}
internal bool ProvidesCorrelation
{
get { return this.providesCorrelation; }
}
public override BindingElement Clone()
{
return new InternalDuplexBindingElement(this);
}
public override IChannelFactory BuildChannelFactory(BindingContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if (!this.CanBuildChannelFactory(context))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(
"TChannel", SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel)));
}
IChannelFactory innerChannelFactory = context.Clone().BuildInnerChannelFactory();
if (this.clientChannelDemuxer == null)
{
this.clientChannelDemuxer = new InputChannelDemuxer(context);
}
else
{
#pragma warning suppress 56506 // [....], context.RemainingBindingElements will never be null
context.RemainingBindingElements.Clear();
}
LocalAddressProvider localAddressProvider = context.BindingParameters.Remove();
return (IChannelFactory)(object)
new InternalDuplexChannelFactory(this, context, this.clientChannelDemuxer, innerChannelFactory, localAddressProvider);
}
public override IChannelListener BuildChannelListener(BindingContext context)
{
if (context == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
}
if (typeof(TChannel) != typeof(IDuplexChannel))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel",
SR.GetString(SR.ChannelTypeNotSupported, typeof(TChannel)));
}
return (IChannelListener)(object)new InternalDuplexChannelListener(this, context);
}
public override bool CanBuildChannelFactory(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
return typeof(TChannel) == typeof(IDuplexChannel)
&& context.CanBuildInnerChannelFactory()
&& context.CanBuildInnerChannelListener();
}
public override bool CanBuildChannelListener(BindingContext context)
{
if (context == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context");
return typeof(TChannel) == typeof(IDuplexChannel)
&& context.CanBuildInnerChannelFactory()
&& context.CanBuildInnerChannelListener();
}
internal static T GetSecurityCapabilities(ISecurityCapabilities lowerCapabilities)
{
DiagnosticUtility.DebugAssert(typeof(T) == typeof(ISecurityCapabilities), "Can only be used with ISecurityCapabilities");
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 (T)(object)null;
}
}
public override T GetProperty(BindingContext context)
{
if (typeof(T) == typeof(ISecurityCapabilities) && !this.ProvidesCorrelation)
{
return InternalDuplexBindingElement.GetSecurityCapabilities(context.GetInnerProperty());
}
else
{
return context.GetInnerProperty();
}
}
internal override bool IsMatch(BindingElement b)
{
if (b == null)
return false;
return (b is InternalDuplexBindingElement);
}
public static void AddDuplexFactorySupport(BindingContext context, ref InternalDuplexBindingElement internalDuplexBindingElement)
{
if (context.CanBuildInnerChannelFactory())
return;
if (context.RemainingBindingElements.Find() == null)
return;
if (context.CanBuildInnerChannelFactory() &&
context.CanBuildInnerChannelListener())
{
if (context.CanBuildInnerChannelFactory())
return;
if (context.CanBuildInnerChannelFactory())
return;
if (context.CanBuildInnerChannelFactory())
return;
if (context.CanBuildInnerChannelFactory())
return;
if (internalDuplexBindingElement == null)
internalDuplexBindingElement = new InternalDuplexBindingElement();
context.RemainingBindingElements.Insert(0, internalDuplexBindingElement);
}
}
public static void AddDuplexListenerSupport(BindingContext context, ref InternalDuplexBindingElement internalDuplexBindingElement)
{
if (context.CanBuildInnerChannelListener())
return;
if (context.RemainingBindingElements.Find() == null)
return;
if (context.CanBuildInnerChannelFactory() &&
context.CanBuildInnerChannelListener())
{
if (context.CanBuildInnerChannelListener())
return;
if (context.CanBuildInnerChannelListener())
return;
if (context.CanBuildInnerChannelListener())
return;
if (context.CanBuildInnerChannelListener())
return;
if (internalDuplexBindingElement == null)
internalDuplexBindingElement = new InternalDuplexBindingElement();
context.RemainingBindingElements.Insert(0, internalDuplexBindingElement);
}
}
public static void AddDuplexListenerSupport(CustomBinding binding, ref InternalDuplexBindingElement internalDuplexBindingElement)
{
if (binding.CanBuildChannelListener())
return;
if (binding.Elements.Find() == null)
return;
if (binding.CanBuildChannelFactory() &&
binding.CanBuildChannelListener())
{
if (binding.CanBuildChannelListener())
return;
if (binding.CanBuildChannelListener())
return;
if (binding.CanBuildChannelListener())
return;
if (binding.CanBuildChannelListener())
return;
if (internalDuplexBindingElement == null)
internalDuplexBindingElement = new InternalDuplexBindingElement();
binding.Elements.Insert(0, internalDuplexBindingElement);
}
}
}
class LocalAddressProvider
{
EndpointAddress localAddress;
MessageFilter filter;
int priority;
public LocalAddressProvider(EndpointAddress localAddress, MessageFilter filter)
{
if (localAddress == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("localAddress");
}
if (filter == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("filter");
}
this.localAddress = localAddress;
this.filter = filter;
if (localAddress.Headers.FindHeader(XD.UtilityDictionary.UniqueEndpointHeaderName.Value,
XD.UtilityDictionary.UniqueEndpointHeaderNamespace.Value) == null)
{
this.priority = Int32.MaxValue - 1;
}
else
{
this.priority = Int32.MaxValue;
}
}
public EndpointAddress LocalAddress
{
get { return this.localAddress; }
}
public MessageFilter Filter
{
get { return this.filter; }
}
public int Priority
{
get { return this.priority; }
}
}
}
// 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
- HttpModuleCollection.cs
- ColorAnimationBase.cs
- XNameConverter.cs
- FrameworkContentElement.cs
- WeakHashtable.cs
- SchemaType.cs
- DataFormats.cs
- AddInControllerImpl.cs
- PointAnimationBase.cs
- ImageAttributes.cs
- IsolatedStorageSecurityState.cs
- EntitySqlQueryBuilder.cs
- HttpModuleCollection.cs
- ToolStripRenderer.cs
- QueryableFilterRepeater.cs
- WizardStepBase.cs
- TypeBrowserDialog.cs
- cookie.cs
- Rfc2898DeriveBytes.cs
- Persist.cs
- TextContainer.cs
- DetailsViewPagerRow.cs
- PackagePartCollection.cs
- EventRouteFactory.cs
- ResponseStream.cs
- Debugger.cs
- assertwrapper.cs
- X509ChainPolicy.cs
- DomNameTable.cs
- ExpressionBuilderContext.cs
- RadioButtonBaseAdapter.cs
- InfoCardSymmetricCrypto.cs
- BindValidator.cs
- Wizard.cs
- Item.cs
- FieldBuilder.cs
- ProxyWebPart.cs
- XmlDocument.cs
- EllipseGeometry.cs
- UnsafeNativeMethods.cs
- webbrowsersite.cs
- QuotedPrintableStream.cs
- ConfigsHelper.cs
- Zone.cs
- ConstantExpression.cs
- LicFileLicenseProvider.cs
- DocumentViewerAutomationPeer.cs
- ToolBarDesigner.cs
- Image.cs
- WindowsToolbarItemAsMenuItem.cs
- InfoCardProofToken.cs
- Comparer.cs
- XmlNodeChangedEventArgs.cs
- StrokeCollection.cs
- InstanceDescriptor.cs
- DataObjectEventArgs.cs
- PropertyChangingEventArgs.cs
- KeyMatchBuilder.cs
- HttpRequest.cs
- AnonymousIdentificationModule.cs
- BasicHttpMessageSecurityElement.cs
- BookmarkScopeHandle.cs
- Soap12ProtocolImporter.cs
- HttpCapabilitiesEvaluator.cs
- BasicExpandProvider.cs
- WorkflowTimerService.cs
- RuleSetBrowserDialog.cs
- XmlUtil.cs
- Validator.cs
- ReverseComparer.cs
- FormattedText.cs
- _AutoWebProxyScriptEngine.cs
- ClientConvert.cs
- RepeaterCommandEventArgs.cs
- _ListenerRequestStream.cs
- BufferModeSettings.cs
- TypeElementCollection.cs
- CodeChecksumPragma.cs
- PolygonHotSpot.cs
- CanonicalXml.cs
- GregorianCalendarHelper.cs
- AdRotator.cs
- SinglePhaseEnlistment.cs
- ProcessProtocolHandler.cs
- ResourceDescriptionAttribute.cs
- FileRecordSequenceHelper.cs
- CodeGeneratorOptions.cs
- ApplicationDirectory.cs
- FollowerQueueCreator.cs
- DispatchWrapper.cs
- CopyNamespacesAction.cs
- ScrollBarAutomationPeer.cs
- DataMemberConverter.cs
- TraceSource.cs
- TrackingDataItemValue.cs
- SQLGuidStorage.cs
- DetailsViewRow.cs
- Viewport3DVisual.cs
- EntryPointNotFoundException.cs
- PeerHopCountAttribute.cs