Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TransportOutputChannel.cs / 1 / TransportOutputChannel.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Collections.Generic;
using System.ServiceModel;
using System.Diagnostics;
using System.Xml;
abstract class TransportOutputChannel : OutputChannel
{
bool anyHeadersToAdd;
bool manualAddressing;
MessageVersion messageVersion;
EndpointAddress to;
Uri via;
ToHeader toHeader;
protected TransportOutputChannel(ChannelManagerBase channelManager, EndpointAddress to, Uri via, bool manualAddressing, MessageVersion messageVersion)
: base(channelManager)
{
this.manualAddressing = manualAddressing;
this.messageVersion = messageVersion;
this.to = to;
this.via = via;
if (!manualAddressing && to != null)
{
Uri toUri;
if (to.IsAnonymous)
{
toUri = this.messageVersion.Addressing.AnonymousUri;
}
else if (to.IsNone)
{
toUri = this.messageVersion.Addressing.NoneUri;
}
else
{
toUri = to.Uri;
}
XmlDictionaryString dictionaryTo = new ToDictionary(toUri.AbsoluteUri).To;
this.toHeader = ToHeader.Create(toUri, dictionaryTo, messageVersion.Addressing);
this.anyHeadersToAdd = to.Headers.Count > 0;
}
}
protected bool ManualAddressing
{
get
{
return this.manualAddressing;
}
}
public MessageVersion MessageVersion
{
get
{
return this.messageVersion;
}
}
public override EndpointAddress RemoteAddress
{
get
{
return this.to;
}
}
public override Uri Via
{
get
{
return this.via;
}
}
protected override void AddHeadersTo(Message message)
{
base.AddHeadersTo(message);
if (toHeader != null)
{
// we don't use to.ApplyTo(message) since it's faster to cache and
// use the actual header then to call message.Headers.To = Uri...
message.Headers.SetToHeader(toHeader);
if (anyHeadersToAdd)
{
to.Headers.AddHeadersTo(message);
}
}
}
class ToDictionary : IXmlDictionary
{
XmlDictionaryString to;
public ToDictionary(string to)
{
this.to = new XmlDictionaryString(this, to, 0);
}
public XmlDictionaryString To
{
get
{
return to;
}
}
public bool TryLookup(string value, out XmlDictionaryString result)
{
if (value == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
if (value == to.Value)
{
result = to;
return true;
}
result = null;
return false;
}
public bool TryLookup(int key, out XmlDictionaryString result)
{
if (key == 0)
{
result = to;
return true;
}
result = null;
return false;
}
public bool TryLookup(XmlDictionaryString value, out XmlDictionaryString result)
{
if (value == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("value");
if (value == to)
{
result = to;
return true;
}
result = null;
return false;
}
}
}
}
// 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
- FixedTextPointer.cs
- ListViewGroupItemCollection.cs
- SettingsSavedEventArgs.cs
- VideoDrawing.cs
- StoryFragments.cs
- RequestCachingSection.cs
- HyperLink.cs
- XmlUtil.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- SecUtil.cs
- GeometryHitTestParameters.cs
- CollectionViewGroup.cs
- SafeNativeMethods.cs
- MessageQuerySet.cs
- ToolStripDropDown.cs
- TextAnchor.cs
- FormatterServices.cs
- MatrixCamera.cs
- MeasureItemEvent.cs
- TreeChangeInfo.cs
- CompilerScopeManager.cs
- Rotation3DAnimationBase.cs
- SchemaExporter.cs
- WebEventTraceProvider.cs
- ActionItem.cs
- Error.cs
- DataGridViewDataConnection.cs
- SchemaManager.cs
- PropertyPath.cs
- FileInfo.cs
- ScaleTransform.cs
- ProfileParameter.cs
- RoutedEventArgs.cs
- ArgIterator.cs
- XmlMemberMapping.cs
- AttachedAnnotationChangedEventArgs.cs
- ToolboxDataAttribute.cs
- HttpProfileBase.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- SchemaInfo.cs
- ServiceChannelProxy.cs
- PageRequestManager.cs
- ConfigurationSectionCollection.cs
- DLinqDataModelProvider.cs
- TypePresenter.xaml.cs
- DirectoryObjectSecurity.cs
- Int32Animation.cs
- TableLayoutPanelCellPosition.cs
- RtfControlWordInfo.cs
- EntityParameter.cs
- DynamicMethod.cs
- DataSourceCacheDurationConverter.cs
- SerializationSectionGroup.cs
- DescendantQuery.cs
- NodeInfo.cs
- UserPrincipalNameElement.cs
- smtppermission.cs
- DSASignatureFormatter.cs
- SimpleWorkerRequest.cs
- DoubleCollectionValueSerializer.cs
- SecurityDocument.cs
- DataGridViewLayoutData.cs
- BitmapSourceSafeMILHandle.cs
- EntityClientCacheEntry.cs
- ListMarkerLine.cs
- Light.cs
- ByteRangeDownloader.cs
- ElementProxy.cs
- IntSecurity.cs
- LongPath.cs
- LogicalExpressionEditor.cs
- RuleSettings.cs
- SelectionEditingBehavior.cs
- SecurityManager.cs
- DocumentApplicationJournalEntry.cs
- IsolationInterop.cs
- SqlUDTStorage.cs
- MenuItemBindingCollection.cs
- Literal.cs
- DocumentPageTextView.cs
- HyperlinkAutomationPeer.cs
- BindingSource.cs
- ParallelQuery.cs
- PolicyValidationException.cs
- WebPartUtil.cs
- ClientData.cs
- PenLineJoinValidation.cs
- xdrvalidator.cs
- TextRangeBase.cs
- PictureBoxDesigner.cs
- Version.cs
- RoutedEventValueSerializer.cs
- HttpUnhandledOperationInvoker.cs
- MarkupProperty.cs
- RightsManagementEncryptionTransform.cs
- ColumnHeaderCollectionEditor.cs
- HMACRIPEMD160.cs
- TraceEventCache.cs
- SmiRecordBuffer.cs
- StringTraceRecord.cs