2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
4 namespace Microsoft
.ServiceModel
.Samples
7 using System
.ServiceModel
.Channels
;
9 abstract class LayeredChannel
<TInnerChannel
> : ChannelBase
10 where TInnerChannel
: class, IChannel
12 TInnerChannel innerChannel
;
13 EventHandler onInnerChannelFaulted
;
15 protected LayeredChannel(ChannelManagerBase channelManager
, TInnerChannel innerChannel
)
16 : base(channelManager
)
18 this.innerChannel
= innerChannel
;
19 this.onInnerChannelFaulted
= new EventHandler(OnInnerChannelFaulted
);
20 this.innerChannel
.Faulted
+= this.onInnerChannelFaulted
;
23 protected TInnerChannel InnerChannel
25 get { return this.innerChannel; }
28 public override T GetProperty
<T
>()
30 T baseProperty
= base.GetProperty
<T
>();
31 if (baseProperty
!= null)
36 return this.InnerChannel
.GetProperty
<T
>();
39 protected override void OnClosing()
41 this.innerChannel
.Faulted
-= this.onInnerChannelFaulted
;
45 protected override void OnAbort()
47 this.innerChannel
.Abort();
50 protected override void OnClose(TimeSpan timeout
)
52 this.innerChannel
.Close(timeout
);
55 protected override IAsyncResult
OnBeginClose(TimeSpan timeout
, AsyncCallback callback
, object state
)
57 return this.innerChannel
.BeginClose(timeout
, callback
, state
);
60 protected override void OnEndClose(IAsyncResult result
)
62 this.innerChannel
.EndClose(result
);
65 protected override void OnOpen(TimeSpan timeout
)
67 this.innerChannel
.Open(timeout
);
70 protected override IAsyncResult
OnBeginOpen(TimeSpan timeout
, AsyncCallback callback
, object state
)
72 return this.innerChannel
.BeginOpen(timeout
, callback
, state
);
75 protected override void OnEndOpen(IAsyncResult result
)
77 this.innerChannel
.EndOpen(result
);
80 void OnInnerChannelFaulted(object sender
, EventArgs e
)