Merge pull request #3528 from BrzVlad/fix-sgen-check-before-collections
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel / DuplexClientBase.cs
index 05593dc141487a2b8a51f1e434e511e52067238f..64ce85812b5dabce76d928c81a1a802369c78231 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2005,2009 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 using System;
 using System.Collections.Generic;
 using System.ServiceModel.Channels;
+using System.ServiceModel.Description;
 
 namespace System.ServiceModel
 {
-       public class DuplexClientBase<TChannel> : ClientBase<TChannel>
+       public class DuplexClientBase<TChannel> : ClientBase<TChannel> where TChannel : class
        {
-               protected DuplexClientBase (InstanceContext instance)
-                       : this (instance, (Binding) null, null)
+               protected DuplexClientBase (object callbackInstance)
+                       : this (new InstanceContext (callbackInstance), (Binding) null, null)
                {
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       Binding binding, EndpointAddress address)
+               protected DuplexClientBase (object callbackInstance,
+                       Binding binding, EndpointAddress remoteAddress)
+                       : this (new InstanceContext (callbackInstance), binding, remoteAddress)
                {
-                       throw new NotImplementedException ();
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       string configurationName)
+               protected DuplexClientBase (object callbackInstance,
+                       string endpointConfigurationName)
+                       : this (new InstanceContext (callbackInstance), endpointConfigurationName)
                {
-                       throw new NotImplementedException ();
                }
 
-               protected DuplexClientBase (InstanceContext instance,
-                       string configurationName, EndpointAddress address)
+               protected DuplexClientBase (object callbackInstance,
+                       string bindingConfigurationName, EndpointAddress remoteAddress)
+                       : this (new InstanceContext (callbackInstance), bindingConfigurationName, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (object callbackInstance,
+                       string endpointConfigurationName, string remoteAddress)
+                       : this (new InstanceContext (callbackInstance), endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance)
+                       : base (callbackInstance)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       Binding binding, EndpointAddress remoteAddress)
+                       : base (callbackInstance, binding, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName)
+                       : base (callbackInstance, endpointConfigurationName)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName, string remoteAddress)
+                       : base (callbackInstance, endpointConfigurationName, remoteAddress)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance,
+                       string endpointConfigurationName, EndpointAddress address)
+                       : base (callbackInstance, endpointConfigurationName, address)
+               {
+               }
+
+               protected DuplexClientBase (object callbackInstance, ServiceEndpoint endpoint)
+                       : this (new InstanceContext (callbackInstance), endpoint)
+               {
+               }
+
+               protected DuplexClientBase (InstanceContext callbackInstance, ServiceEndpoint endpoint)
+                       : base (callbackInstance, endpoint)
                {
-                       throw new NotImplementedException ();
                }
 
                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 ();
                }
        }
 }