Merge pull request #4453 from lambdageek/bug-49721
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel / DuplexClientBase.cs
index 649bb771a4c56ee45be8ade18bb6124a54403cae..c51ce43a77739320e33d3ba989049d01ae512b86 100644 (file)
 using System;
 using System.Collections.Generic;
 using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
 
 namespace System.ServiceModel
 {
        public class DuplexClientBase<TChannel> : ClientBase<TChannel> where TChannel : class
        {
-               protected DuplexClientBase (object instance)
-                       : this (new InstanceContext (instance), (Binding) null, null)
+               protected DuplexClientBase (object callbackInstance)
+                       : this (new InstanceContext (callbackInstance), (Binding) null, null)
                {
                }
 
-               protected DuplexClientBase (object instance,
-                       Binding binding, EndpointAddress address)
-                       : this (new InstanceContext (instance), binding, address)
+               protected DuplexClientBase (object callbackInstance,
+                       Binding binding, EndpointAddress remoteAddress)
+                       : this (new InstanceContext (callbackInstance), binding, remoteAddress)
                {
                }
 
-               protected DuplexClientBase (object instance,
-                       string configurationName)
-                       : this (new InstanceContext (instance), configurationName)
+               protected DuplexClientBase (object callbackInstance,
+                       string endpointConfigurationName)
+                       : this (new InstanceContext (callbackInstance), endpointConfigurationName)
                {
                }
 
-               protected DuplexClientBase (object instance,
-                       string bindingConfigurationName, EndpointAddress address)
-                       : this (new InstanceContext (instance), bindingConfigurationName, address)
+               protected DuplexClientBase (object callbackInstance,
+                       string endpointConfigurationName, EndpointAddress remoteAddress)
+                       : this (new InstanceContext (callbackInstance), endpointConfigurationName, remoteAddress)
                {
                }
 
-               protected DuplexClientBase (InstanceContext instance)
-                       : base ()
+               protected DuplexClientBase (object callbackInstance,
+                       string endpointConfigurationName, string remoteAddress)
+                       : this (new InstanceContext (callbackInstance), endpointConfigurationName, remoteAddress)
                {
-                       this.instance = instance;
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       Binding binding, EndpointAddress address)
-                       : base (binding, address)
+               protected DuplexClientBase (InstanceContext callbackInstance)
+                       : base (callbackInstance)
                {
-                       this.instance = instance;
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       string configurationName)
-                       : base (configurationName)
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       Binding binding, EndpointAddress remoteAddress)
+                       : base (callbackInstance, binding, remoteAddress)
                {
-                       this.instance = instance;
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       string configurationName, EndpointAddress address)
-                       : base (configurationName, address)
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName)
+                       : base (callbackInstance, endpointConfigurationName)
                {
-                       this.instance = instance;
                }
 
-               InstanceContext instance;
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName, string remoteAddress)
+                       : base (callbackInstance, endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName, EndpointAddress remoteAddress)
+                       : base (callbackInstance, endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (object callbackInstance, ServiceEndpoint endpoint)
+                       : this (new InstanceContext (callbackInstance), endpoint)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance, ServiceEndpoint endpoint)
+                       : base (callbackInstance, endpoint)
+               {
+               }
 
                public IDuplexContextChannel InnerDuplexChannel {
-                       get { throw new NotImplementedException (); }
+                       get { return (IDuplexContextChannel) base.InnerChannel; }
+               }
+
+               internal override void Initialize (InstanceContext instance,
+                       string endpointConfigurationName, EndpointAddress remoteAddress)
+               {
+                       ChannelFactory = new DuplexChannelFactory<TChannel> (instance, endpointConfigurationName, remoteAddress);
+               }
+
+               internal override void Initialize (InstanceContext instance,
+                       Binding binding, EndpointAddress remoteAddress)
+               {
+                       ChannelFactory = new DuplexChannelFactory<TChannel> (instance, binding, remoteAddress);
                }
 
                protected override TChannel CreateChannel ()
                {
-                       throw new NotImplementedException ();
+                       return ChannelFactory.CreateChannel ();
                }
        }
 }