Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / ChannelBuilder.cs / 1 / ChannelBuilder.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
using System.ServiceModel.Dispatcher;
class ChannelBuilder
{
CustomBinding binding;
BindingContext context;
BindingParameterCollection bindingParameters;
Uri listenUri;
public ChannelBuilder(BindingContext context, bool addChannelDemuxerIfRequired)
{
this.context = context;
if (addChannelDemuxerIfRequired)
{
this.AddDemuxerBindingElement(context.RemainingBindingElements);
}
this.binding = new CustomBinding(context.Binding, context.RemainingBindingElements);
this.bindingParameters = context.BindingParameters;
}
public ChannelBuilder(Binding binding, BindingParameterCollection bindingParameters, bool addChannelDemuxerIfRequired)
{
this.binding = new CustomBinding(binding);
this.bindingParameters = bindingParameters;
if (addChannelDemuxerIfRequired)
{
this.AddDemuxerBindingElement(this.binding.Elements);
}
}
public ChannelBuilder(ChannelBuilder channelBuilder)
{
this.binding = new CustomBinding(channelBuilder.Binding);
this.bindingParameters = channelBuilder.BindingParameters;
if (this.binding.Elements.Find() == null)
{
DiagnosticUtility.DebugAssert("ChannelBuilder.ctor (this.binding.Elements.Find() != null)");
throw DiagnosticUtility.ExceptionUtility.ThrowHelperInternal(false);
}
}
public CustomBinding Binding
{
get { return this.binding; }
set { this.binding = value; }
}
public BindingParameterCollection BindingParameters
{
get { return this.bindingParameters; }
set { this.bindingParameters = value; }
}
void AddDemuxerBindingElement(BindingElementCollection elements)
{
if (elements.Find() == null)
{
// add the channel demuxer binding element right above the transport
TransportBindingElement transport = elements.Find();
if (transport == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TransportBindingElementNotFound)));
}
// cache the context state in the demuxer so that the same context state can be provided to the transport
// when building auxilliary channels and listeners (for ex, for security negotiation)
elements.Insert(elements.IndexOf(transport), new ChannelDemuxerBindingElement(true));
}
}
public IChannelFactory BuildChannelFactory()
{
if (this.context != null)
{
IChannelFactory factory = this.context.BuildInnerChannelFactory();
this.context = null;
return factory;
}
else
{
return this.binding.BuildChannelFactory(this.bindingParameters);
}
}
public IChannelListener BuildChannelListener() where TChannel : class, IChannel
{
if (this.context != null)
{
IChannelListener listener = this.context.BuildInnerChannelListener();
this.listenUri = listener.Uri;
this.context = null;
return listener;
}
else
{
return this.binding.BuildChannelListener(this.listenUri, this.bindingParameters);
}
}
public IChannelListener BuildChannelListener(MessageFilter filter, int priority) where TChannel : class, IChannel
{
this.bindingParameters.Add(new ChannelDemuxerFilter(filter, priority));
IChannelListener listener = this.BuildChannelListener();
this.bindingParameters.Remove();
return listener;
}
public bool CanBuildChannelFactory()
{
return this.binding.CanBuildChannelFactory(this.bindingParameters);
}
public bool CanBuildChannelListener() where TChannel : class, IChannel
{
return this.binding.CanBuildChannelListener(this.bindingParameters);
}
}
}
// 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
- AuthenticationSection.cs
- TextEditorTables.cs
- SchemaMerger.cs
- DBNull.cs
- SqlCacheDependencySection.cs
- DerivedKeyCachingSecurityTokenSerializer.cs
- PipeException.cs
- NetworkStream.cs
- AsyncResult.cs
- XmlSchemaImport.cs
- DataGridViewLinkColumn.cs
- BitmapEffect.cs
- DesignerInterfaces.cs
- WorkflowMarkupSerializerMapping.cs
- ObjectDataSourceMethodEventArgs.cs
- SecurityUniqueId.cs
- CacheForPrimitiveTypes.cs
- DataGridViewMethods.cs
- HtmlShim.cs
- ConditionedDesigner.cs
- MemoryMappedViewAccessor.cs
- DesignerProperties.cs
- XamlSerializer.cs
- Win32.cs
- TypeInformation.cs
- PointHitTestResult.cs
- ConfigDefinitionUpdates.cs
- TimelineGroup.cs
- ReaderOutput.cs
- XmlSchemaDatatype.cs
- ContentTextAutomationPeer.cs
- XmlDigitalSignatureProcessor.cs
- Matrix3DStack.cs
- CodeTryCatchFinallyStatement.cs
- ContractInferenceHelper.cs
- PersonalizationProvider.cs
- XamlTemplateSerializer.cs
- DecoderFallbackWithFailureFlag.cs
- LambdaCompiler.Lambda.cs
- RectangleGeometry.cs
- PolicyException.cs
- CompositeCollection.cs
- TypeUsageBuilder.cs
- ReflectTypeDescriptionProvider.cs
- PackagingUtilities.cs
- ListViewHitTestInfo.cs
- EqualityComparer.cs
- loginstatus.cs
- XmlSchemaGroupRef.cs
- NativeStructs.cs
- ScriptServiceAttribute.cs
- MouseGestureConverter.cs
- SqlDataSourceCustomCommandEditor.cs
- ToolStripDropDownItemDesigner.cs
- HelpProvider.cs
- mongolianshape.cs
- _WebProxyDataBuilder.cs
- XPathNavigatorKeyComparer.cs
- LocalizedNameDescriptionPair.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- FixedStringLookup.cs
- NetSectionGroup.cs
- DocumentPageHost.cs
- HyperLinkField.cs
- NameSpaceExtractor.cs
- LoginNameDesigner.cs
- BStrWrapper.cs
- DataConnectionHelper.cs
- WebPartDisplayModeCollection.cs
- RowToParametersTransformer.cs
- HtmlInputButton.cs
- AppSettingsSection.cs
- XmlLanguage.cs
- ProgressChangedEventArgs.cs
- NativeMethods.cs
- WebPartCollection.cs
- SqlNamer.cs
- ComponentManagerBroker.cs
- WebResourceUtil.cs
- SerializationInfo.cs
- ImageListStreamer.cs
- FieldDescriptor.cs
- SystemTcpStatistics.cs
- RowBinding.cs
- SettingsPropertyNotFoundException.cs
- TypeHelper.cs
- XPathPatternBuilder.cs
- safex509handles.cs
- ControlEvent.cs
- WindowsListViewSubItem.cs
- VersionUtil.cs
- iisPickupDirectory.cs
- OleDbCommand.cs
- MobileListItemCollection.cs
- AsyncPostBackErrorEventArgs.cs
- XmlSerializationReader.cs
- COAUTHIDENTITY.cs
- BinaryParser.cs
- XmlILOptimizerVisitor.cs
- DefaultSerializationProviderAttribute.cs