1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace System.ServiceModel.Channels
{
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Diagnostics;
public abstract class ChannelBase : CommunicationObject, IChannel, IDefaultCommunicationTimeouts
{
ChannelManagerBase channelManager;
protected ChannelBase(ChannelManagerBase channelManager)
{
if (channelManager == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelManager");
}
this.channelManager = channelManager;
if (DiagnosticUtility.ShouldTraceVerbose)
{
TraceUtility.TraceEvent(TraceEventType.Verbose, TraceCode.ChannelCreated,
SR.GetString(SR.TraceCodeChannelCreated, TraceUtility.CreateSourceString(this)), this);
}
}
TimeSpan IDefaultCommunicationTimeouts.CloseTimeout
{
get { return this.DefaultCloseTimeout; }
}
TimeSpan IDefaultCommunicationTimeouts.OpenTimeout
{
get { return this.DefaultOpenTimeout; }
}
TimeSpan IDefaultCommunicationTimeouts.ReceiveTimeout
{
get { return this.DefaultReceiveTimeout; }
}
TimeSpan IDefaultCommunicationTimeouts.SendTimeout
{
get { return this.DefaultSendTimeout; }
}
protected override TimeSpan DefaultCloseTimeout
{
get { return ((IDefaultCommunicationTimeouts)this.channelManager).CloseTimeout; }
}
protected override TimeSpan DefaultOpenTimeout
{
get { return ((IDefaultCommunicationTimeouts)this.channelManager).OpenTimeout; }
}
protected TimeSpan DefaultReceiveTimeout
{
get { return ((IDefaultCommunicationTimeouts)this.channelManager).ReceiveTimeout; }
}
protected TimeSpan DefaultSendTimeout
{
get { return ((IDefaultCommunicationTimeouts)this.channelManager).SendTimeout; }
}
protected ChannelManagerBase Manager
{
get
{
return channelManager;
}
}
public virtual T GetProperty<T>() where T : class
{
IChannelFactory factory = this.channelManager as IChannelFactory;
if (factory != null)
{
return factory.GetProperty<T>();
}
IChannelListener listener = this.channelManager as IChannelListener;
if (listener != null)
{
return listener.GetProperty<T>();
}
return null;
}
protected override void OnClosed()
{
base.OnClosed();
if (DiagnosticUtility.ShouldTraceVerbose)
{
TraceUtility.TraceEvent(TraceEventType.Verbose, TraceCode.ChannelDisposed,
SR.GetString(SR.TraceCodeChannelDisposed, TraceUtility.CreateSourceString(this)), this);
}
}
}
}
|