Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Security / SecurityChannel.cs / 1 / SecurityChannel.cs
//----------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.ServiceModel.Security
{
using System.ServiceModel.Channels;
abstract class SecurityChannel :
LayeredChannel
where TChannel : class, IChannel
{
SecurityProtocol securityProtocol;
protected SecurityChannel(ChannelManagerBase channelManager, TChannel innerChannel)
: this(channelManager, innerChannel, null)
{
}
protected SecurityChannel(ChannelManagerBase channelManager, TChannel innerChannel, SecurityProtocol securityProtocol)
: base(channelManager, innerChannel)
{
this.securityProtocol = securityProtocol;
}
public override T GetProperty()
{
if(typeof(T) == typeof(FaultConverter))
{
return new SecurityChannelFaultConverter(this.InnerChannel) as T;
}
return base.GetProperty();
}
public SecurityProtocol SecurityProtocol
{
get
{
return this.securityProtocol;
}
protected set
{
if (value == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("value"));
}
this.securityProtocol = value;
}
}
protected override void OnAbort()
{
if (this.securityProtocol != null)
{
this.securityProtocol.Close(true, TimeSpan.Zero);
}
base.OnAbort();
}
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
{
return new ChainedAsyncResult(timeout, callback, state, this.BeginCloseSecurityProtocol, this.EndCloseSecurityProtocol,
base.OnBeginClose, base.OnEndClose);
}
protected override void OnEndClose(IAsyncResult result)
{
ChainedAsyncResult.End(result);
}
IAsyncResult BeginCloseSecurityProtocol(TimeSpan timeout, AsyncCallback callback, object state)
{
if (this.securityProtocol != null)
{
return this.securityProtocol.BeginClose(timeout, callback, state);
}
else
{
return new NullSecurityProtocolCloseAsyncResult(callback, state);
}
}
void EndCloseSecurityProtocol(IAsyncResult result)
{
if (result is NullSecurityProtocolCloseAsyncResult)
{
NullSecurityProtocolCloseAsyncResult.End(result);
}
else
{
this.securityProtocol.EndClose(result);
}
}
protected override void OnClose(TimeSpan timeout)
{
TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
if (this.securityProtocol != null)
{
this.securityProtocol.Close(false, timeoutHelper.RemainingTime());
}
base.OnClose(timeoutHelper.RemainingTime());
}
protected void ThrowIfDisposedOrNotOpen(Message message)
{
ThrowIfDisposedOrNotOpen();
if (message == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
}
}
class NullSecurityProtocolCloseAsyncResult : CompletedAsyncResult
{
public NullSecurityProtocolCloseAsyncResult(AsyncCallback callback, object state)
: base(callback, state)
{
}
new public static void End(IAsyncResult result)
{
AsyncResult.End(result);
}
}
protected sealed class OutputChannelSendAsyncResult : ApplySecurityAndSendAsyncResult
{
public OutputChannelSendAsyncResult(Message message, SecurityProtocol binding, IOutputChannel channel, TimeSpan timeout,
AsyncCallback callback, object state)
: base(binding, channel, timeout, callback, state)
{
this.Begin(message, null);
}
protected override IAsyncResult BeginSendCore(IOutputChannel channel, Message message, TimeSpan timeout, AsyncCallback callback, object state)
{
return channel.BeginSend(message, timeout, callback, state);
}
internal static void End(IAsyncResult result)
{
OutputChannelSendAsyncResult self = result as OutputChannelSendAsyncResult;
OnEnd(self);
}
protected override void EndSendCore(IOutputChannel channel, IAsyncResult result)
{
channel.EndSend(result);
}
protected override void OnSendCompleteCore(TimeSpan timeout)
{
}
}
}
}
// 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
- StringFormat.cs
- XamlHostingSectionGroup.cs
- _OSSOCK.cs
- WorkflowTransactionService.cs
- TripleDESCryptoServiceProvider.cs
- PropertyGridView.cs
- ConditionalAttribute.cs
- NativeMethods.cs
- Item.cs
- ResourceReferenceKeyNotFoundException.cs
- WsatTransactionInfo.cs
- PingReply.cs
- Assert.cs
- DeferrableContent.cs
- DtrList.cs
- SqlCacheDependencyDatabaseCollection.cs
- _TimerThread.cs
- DataRow.cs
- OutputCacheProfileCollection.cs
- DiagnosticsConfiguration.cs
- PolyBezierSegment.cs
- BamlRecordHelper.cs
- ResourceDisplayNameAttribute.cs
- HMACSHA256.cs
- SqlRowUpdatedEvent.cs
- UIElement3D.cs
- RequestCache.cs
- SignatureHelper.cs
- RemotingServices.cs
- ListItemCollection.cs
- Funcletizer.cs
- KernelTypeValidation.cs
- ChangeDirector.cs
- Menu.cs
- CriticalFinalizerObject.cs
- XamlParser.cs
- CollectionView.cs
- Latin1Encoding.cs
- ActivationArguments.cs
- MultilineStringEditor.cs
- MetadataPropertyCollection.cs
- CodeAttributeDeclarationCollection.cs
- WindowsListViewItemStartMenu.cs
- IODescriptionAttribute.cs
- HTTPNotFoundHandler.cs
- TemplatedAdorner.cs
- DataGridViewComboBoxCell.cs
- RelationshipFixer.cs
- TypeGeneratedEventArgs.cs
- FilterFactory.cs
- JsonDataContract.cs
- DbModificationClause.cs
- InvokePattern.cs
- PeerNodeTraceRecord.cs
- AdornerPresentationContext.cs
- GPPOINT.cs
- GridPattern.cs
- XmlSchemaProviderAttribute.cs
- CodeSubDirectory.cs
- ColumnPropertiesGroup.cs
- MediaSystem.cs
- XpsFilter.cs
- ListViewGroupConverter.cs
- LongSumAggregationOperator.cs
- DocumentSchemaValidator.cs
- GeneralTransformGroup.cs
- HandledEventArgs.cs
- SqlWriter.cs
- IItemProperties.cs
- DecoratedNameAttribute.cs
- DataError.cs
- ManualResetEvent.cs
- CultureInfoConverter.cs
- WorkflowInstanceExtensionManager.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- HeaderCollection.cs
- FormViewUpdateEventArgs.cs
- TrackingServices.cs
- IntSecurity.cs
- _Events.cs
- UTF7Encoding.cs
- TextDecorations.cs
- ObjectListFieldsPage.cs
- CornerRadius.cs
- UnaryNode.cs
- ImageCodecInfo.cs
- BitmapCacheBrush.cs
- StaticSiteMapProvider.cs
- CapabilitiesRule.cs
- BackStopAuthenticationModule.cs
- Module.cs
- WebControlParameterProxy.cs
- SafeFileMapViewHandle.cs
- Panel.cs
- HtmlUtf8RawTextWriter.cs
- AxisAngleRotation3D.cs
- ToolStripDropDownClosingEventArgs.cs
- PageVisual.cs
- WindowsAuthenticationEventArgs.cs
- RoleService.cs