Merge pull request #1909 from esdrubal/reflection
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel.Dispatcher / Bug652331_2Test.cs
1 //
2 // Authors:
3 //      David Straw
4 //      Atsushi Enomoto <atsushi@ximian.com>
5 //
6 // Copyright (C) 2011 Novell, Inc.  http://www.novell.com
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //
27 using System;
28 using System.Collections.Generic;
29 using System.Collections.ObjectModel;
30 using System.Linq;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Description;
34 using System.Threading;
35 using NUnit.Framework;
36
37 using WebServiceMoonlightTest.ServiceReference2;
38
39 using MonoTests.Helpers;
40
41 namespace MonoTests.System.ServiceModel.Dispatcher
42 {
43         [TestFixture]
44         public class Bug652331_2Test
45         {
46                 [Test]
47                 [Category ("NotWorking")]
48                 public void Bug652331_3 ()
49                 {
50                         // Init service
51                         ServiceHost serviceHost = new ServiceHost(typeof(Service1), new Uri("http://localhost:" + NetworkHelpers.FindFreePort () + "/Service1"));
52                         serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), string.Empty);
53
54                         // Enable metadata exchange (WSDL publishing)
55                         ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
56                         mexBehavior.HttpGetEnabled = true;
57                         serviceHost.Description.Behaviors.Add(mexBehavior);
58                         serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
59
60                         serviceHost.Open();
61
62                         try {
63                                 RunClient ();
64                         } finally {
65                                 serviceHost.Close ();
66                         }
67                 }
68
69                 void RunClient ()
70                 {
71                         var binding = new BasicHttpBinding ();
72                         var remoteAddress = new EndpointAddress ("http://localhost:" + NetworkHelpers.FindFreePort () + "/Service1");
73
74                         var normalClient      = new Service1Client (binding, remoteAddress);
75                         var collectionClient  = new Service1Client (binding, remoteAddress);
76                         var nestedClient      = new Service1Client (binding, remoteAddress);
77                         var dbClient          = new Service1Client (binding, remoteAddress);
78
79                         var waits = new ManualResetEvent [4];
80                         for (int i = 0; i < waits.Length; i++)
81                                 waits [i] = new ManualResetEvent (false);
82
83                         int passed = 0;
84
85                         normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
86                                 if (e.Error != null) {
87                                         Assert.Fail ("Normal failed; error: {0}", e.Error);
88                                         throw e.Error;
89                                 }
90                                 Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal");
91                                 Interlocked.Increment (ref passed);
92                                 waits [0].Set ();
93                         };
94                         normalClient.GetDataAsync ();
95
96                         collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
97                                 if (e.Error != null) {
98                                         Assert.Fail ("Collection failed; error: {0}", e.Error);
99                                         throw e.Error;
100                                 }
101                                 Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection");
102                                 Interlocked.Increment (ref passed);
103                                 waits [1].Set ();
104                         };
105                         collectionClient.GetCollectionDataAsync ();
106
107                         nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
108                                 if (e.Error != null) {
109                                         Assert.Fail ("Nested failed; error: {0}", e.Error);
110                                         throw e.Error;
111                                 }
112                                 Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested");
113                                 Interlocked.Increment (ref passed);
114                                 waits [2].Set ();
115                         };
116                         nestedClient.GetNestedDataAsync ();
117
118                         dbClient.JSMGetDatabasesCompleted += delegate (object sender, JSMGetDatabasesCompletedEventArgs e) {
119                                 waits [3].Set ();
120                                 if (e.Error != null) {
121                                         throw e.Error;
122                                 }
123                                 Assert.AreEqual ("databases", e.Result, "Databases");
124                                 Interlocked.Increment (ref passed);
125                         };
126                         dbClient.JSMGetDatabasesAsync();
127
128                         WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1));
129                         if (passed != waits.Length)
130                                 Assert.Fail ("Not all tests passed!");
131                 }
132
133                 string ItemsToString (IEnumerable<DataType1> items)
134                 {
135                         return items.Aggregate ((string) null, (result, item) => result == null ? item.Id : result + "," + item.Id);
136                 }
137         }
138
139         public class Service1 : IService1
140         {
141                 public object GetData()
142                 {
143                         return new DataType1 { Id = "A" };
144                 }
145
146                 Func<object> gd;
147                 public IAsyncResult BeginGetData(AsyncCallback cb, object st)
148                 {
149                         gd = new Func<object> (GetData);
150                         return gd.BeginInvoke (cb, st);
151                 }
152
153                 public object EndGetData (IAsyncResult result)
154                 {
155                         return gd.EndInvoke (result);
156                 }
157
158                 public ObservableCollection<object> GetCollectionData()
159                 {
160                         return new ObservableCollection<object> { new DataType1 { Id = "B" }, new DataType1 { Id = "C" } };
161                 }
162
163                 Func<ObservableCollection<object>> gcd;
164                 public IAsyncResult BeginGetCollectionData(AsyncCallback cb, object st)
165                 {
166                         gcd = new Func<ObservableCollection<object>> (GetCollectionData);
167                         return gcd.BeginInvoke (cb, st);
168                 }
169
170                 public ObservableCollection<object> EndGetCollectionData (IAsyncResult result)
171                 {
172                         return gcd.EndInvoke (result);
173                 }
174
175                 public DataType2 GetNestedData()
176                 {
177                         return new DataType2 { Items = new ObservableCollection<object> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
178                 }
179
180                 Func<DataType2> gnd;
181                 public IAsyncResult BeginGetNestedData(AsyncCallback cb, object st)
182                 {
183                         gnd = new Func<DataType2> (GetNestedData);
184                         return gnd.BeginInvoke (cb, st);
185                 }
186
187                 public DataType2 EndGetNestedData (IAsyncResult result)
188                 {
189                         return gnd.EndInvoke (result);
190                 }
191
192                 public JSMGetDatabasesResponse JSMGetDatabases(JSMGetDatabasesRequest request)
193                 {
194                         return new JSMGetDatabasesResponse { JSMGetDatabasesResult = "databases" };
195                 }
196
197                 Func<JSMGetDatabasesRequest, JSMGetDatabasesResponse> gjgdb;
198                 public IAsyncResult BeginJSMGetDatabases(JSMGetDatabasesRequest request, AsyncCallback callback, object asyncState)
199                 {
200                         gjgdb = JSMGetDatabases;
201                         return gjgdb.BeginInvoke (request, callback, asyncState);
202                 }
203
204                 public JSMGetDatabasesResponse EndJSMGetDatabases(IAsyncResult result)
205                 {
206                         return gjgdb.EndInvoke (result);
207                 }
208         }
209 }
210
211
212 //------------------------------------------------------------------------------
213 // <auto-generated>
214 //     This code was generated by a tool.
215 //     Runtime Version:4.0.30319.372
216 //
217 //     Changes to this file may cause incorrect behavior and will be lost if
218 //     the code is regenerated.
219 // </auto-generated>
220 //------------------------------------------------------------------------------
221
222 // 
223 // This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
224 // 
225 namespace WebServiceMoonlightTest.ServiceReference2 {
226     using System.Runtime.Serialization;
227     
228     
229     [System.Diagnostics.DebuggerStepThroughAttribute()]
230     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
231     [System.Runtime.Serialization.DataContractAttribute(Name="DataType1", Namespace="http://mynamespace")]
232     public partial class DataType1 : object, System.ComponentModel.INotifyPropertyChanged {
233         
234         private string IdField;
235         
236         [System.Runtime.Serialization.DataMemberAttribute()]
237         public string Id {
238             get {
239                 return this.IdField;
240             }
241             set {
242                 if ((object.ReferenceEquals(this.IdField, value) != true)) {
243                     this.IdField = value;
244                     this.RaisePropertyChanged("Id");
245                 }
246             }
247         }
248         
249         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
250         
251         protected void RaisePropertyChanged(string propertyName) {
252             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
253             if ((propertyChanged != null)) {
254                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
255             }
256         }
257     }
258     
259     [System.Diagnostics.DebuggerStepThroughAttribute()]
260     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
261     [System.Runtime.Serialization.DataContractAttribute(Name="DataType2", Namespace="http://mynamespace")]
262     [System.Runtime.Serialization.KnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
263     [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
264     public partial class DataType2 : object, System.ComponentModel.INotifyPropertyChanged {
265         
266         private System.Collections.ObjectModel.ObservableCollection<object> ItemsField;
267         
268         [System.Runtime.Serialization.DataMemberAttribute()]
269         public System.Collections.ObjectModel.ObservableCollection<object> Items {
270             get {
271                 return this.ItemsField;
272             }
273             set {
274                 if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
275                     this.ItemsField = value;
276                     this.RaisePropertyChanged("Items");
277                 }
278             }
279         }
280         
281         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
282         
283         protected void RaisePropertyChanged(string propertyName) {
284             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
285             if ((propertyChanged != null)) {
286                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
287             }
288         }
289     }
290     
291     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
292     [System.ServiceModel.ServiceContractAttribute(Namespace="http://mynamespace", ConfigurationName="ServiceReference1.IService1")]
293     public interface IService1 {
294         
295         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetData", ReplyAction="http://mynamespace/IService1/GetDataResponse")]
296         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
297         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
298         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
299         System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState);
300         
301         object EndGetData(System.IAsyncResult result);
302         
303         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetCollectionData", ReplyAction="http://mynamespace/IService1/GetCollectionDataResponse")]
304         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
305         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
306         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
307         System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState);
308         
309         System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result);
310         
311         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetNestedData", ReplyAction="http://mynamespace/IService1/GetNestedDataResponse")]
312         System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState);
313         
314         WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result);
315
316         [System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://mynamespace/IService1/JSMGetDatabases", ReplyAction = "http://mynamespace/IService1/JSMGetDatabasesResponse")]
317         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(object[]))]
318         System.IAsyncResult BeginJSMGetDatabases(JSMGetDatabasesRequest request, System.AsyncCallback callback, object asyncState);
319
320         JSMGetDatabasesResponse EndJSMGetDatabases(System.IAsyncResult result);
321     }
322
323 #region JSMGetDatabases
324     [System.Diagnostics.DebuggerStepThroughAttribute()]
325     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
326     [System.ServiceModel.MessageContractAttribute(WrapperName = "JSMGetDatabases", WrapperNamespace = "", IsWrapped = true)]
327     public partial class JSMGetDatabasesRequest
328     {
329
330         public JSMGetDatabasesRequest()
331         {
332         }
333     }
334
335     [System.Diagnostics.DebuggerStepThroughAttribute()]
336     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
337     [System.ServiceModel.MessageContractAttribute(WrapperName = "JSMGetDatabasesResponse", WrapperNamespace = "", IsWrapped = true)]
338     public partial class JSMGetDatabasesResponse
339     {
340
341         [System.ServiceModel.MessageBodyMemberAttribute(Namespace = "", Order = 0)]
342         [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)]
343         public string JSMGetDatabasesResult;
344
345         public JSMGetDatabasesResponse()
346         {
347         }
348
349         public JSMGetDatabasesResponse(string JSMGetDatabasesResult)
350         {
351             this.JSMGetDatabasesResult = JSMGetDatabasesResult;
352         }
353     }
354 #endregion
355
356     
357     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
358     public interface IService1Channel : WebServiceMoonlightTest.ServiceReference2.IService1, System.ServiceModel.IClientChannel {
359     }
360     
361     [System.Diagnostics.DebuggerStepThroughAttribute()]
362     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
363     public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
364         
365         private object[] results;
366         
367         public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
368                 base(exception, cancelled, userState) {
369             this.results = results;
370         }
371         
372         public object Result {
373             get {
374                 base.RaiseExceptionIfNecessary();
375                 return ((object)(this.results[0]));
376             }
377         }
378     }
379     
380     [System.Diagnostics.DebuggerStepThroughAttribute()]
381     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
382     public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
383         
384         private object[] results;
385         
386         public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
387                 base(exception, cancelled, userState) {
388             this.results = results;
389         }
390         
391         public System.Collections.ObjectModel.ObservableCollection<object> Result {
392             get {
393                 base.RaiseExceptionIfNecessary();
394                 return ((System.Collections.ObjectModel.ObservableCollection<object>)(this.results[0]));
395             }
396         }
397     }
398     
399     [System.Diagnostics.DebuggerStepThroughAttribute()]
400     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
401     public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
402         
403         private object[] results;
404         
405         public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
406                 base(exception, cancelled, userState) {
407             this.results = results;
408         }
409         
410         public WebServiceMoonlightTest.ServiceReference2.DataType2 Result {
411             get {
412                 base.RaiseExceptionIfNecessary();
413                 return ((WebServiceMoonlightTest.ServiceReference2.DataType2)(this.results[0]));
414             }
415         }
416     }
417
418     [System.Diagnostics.DebuggerStepThroughAttribute()]
419     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
420     public partial class JSMGetDatabasesCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs
421     {
422
423         private object[] results;
424
425         public JSMGetDatabasesCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
426             base(exception, cancelled, userState)
427         {
428             this.results = results;
429         }
430
431         public string Result
432         {
433             get
434             {
435                 base.RaiseExceptionIfNecessary();
436                 return ((string)(this.results[0]));
437             }
438         }
439     }
440     
441     [System.Diagnostics.DebuggerStepThroughAttribute()]
442     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
443     public partial class Service1Client : System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
444         
445         private BeginOperationDelegate onBeginGetDataDelegate;
446         
447         private EndOperationDelegate onEndGetDataDelegate;
448         
449         private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
450         
451         private BeginOperationDelegate onBeginGetCollectionDataDelegate;
452         
453         private EndOperationDelegate onEndGetCollectionDataDelegate;
454         
455         private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
456         
457         private BeginOperationDelegate onBeginGetNestedDataDelegate;
458         
459         private EndOperationDelegate onEndGetNestedDataDelegate;
460         
461         private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
462         
463         private BeginOperationDelegate onBeginOpenDelegate;
464         
465         private EndOperationDelegate onEndOpenDelegate;
466         
467         private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
468         
469         private BeginOperationDelegate onBeginCloseDelegate;
470         
471         private EndOperationDelegate onEndCloseDelegate;
472         
473         private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
474         
475 #region JSMGetDatabasesDelegates
476         private BeginOperationDelegate onBeginJSMGetDatabasesDelegate;
477
478         private EndOperationDelegate onEndJSMGetDatabasesDelegate;
479
480         private System.Threading.SendOrPostCallback onJSMGetDatabasesCompletedDelegate;
481 #endregion
482
483         public Service1Client() {
484         }
485         
486         public Service1Client(string endpointConfigurationName) : 
487                 base(endpointConfigurationName) {
488         }
489         
490         public Service1Client(string endpointConfigurationName, string remoteAddress) : 
491                 base(endpointConfigurationName, remoteAddress) {
492         }
493         
494         public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
495                 base(endpointConfigurationName, remoteAddress) {
496         }
497         
498         public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
499                 base(binding, remoteAddress) {
500         }
501         
502 /*
503         public System.Net.CookieContainer CookieContainer {
504             get {
505                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
506                 if ((httpCookieContainerManager != null)) {
507                     return httpCookieContainerManager.CookieContainer;
508                 }
509                 else {
510                     return null;
511                 }
512             }
513             set {
514                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
515                 if ((httpCookieContainerManager != null)) {
516                     httpCookieContainerManager.CookieContainer = value;
517                 }
518                 else {
519                     throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
520                             "ookieContainerBindingElement.");
521                 }
522             }
523         }
524 */
525         
526         public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
527         
528         public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
529         
530         public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
531         
532         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
533         
534         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
535
536         public event System.EventHandler<JSMGetDatabasesCompletedEventArgs> JSMGetDatabasesCompleted;
537
538         
539         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
540         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetData(System.AsyncCallback callback, object asyncState) {
541             return base.Channel.BeginGetData(callback, asyncState);
542         }
543         
544         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
545         object WebServiceMoonlightTest.ServiceReference2.IService1.EndGetData(System.IAsyncResult result) {
546             return base.Channel.EndGetData(result);
547         }
548         
549         private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
550             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetData(callback, asyncState);
551         }
552         
553         private object[] OnEndGetData(System.IAsyncResult result) {
554             object retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetData(result);
555             return new object[] {
556                     retVal};
557         }
558         
559         private void OnGetDataCompleted(object state) {
560             if ((this.GetDataCompleted != null)) {
561                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
562                 this.GetDataCompleted(this, new GetDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
563             }
564         }
565         
566         public void GetDataAsync() {
567             this.GetDataAsync(null);
568         }
569         
570         public void GetDataAsync(object userState) {
571             if ((this.onBeginGetDataDelegate == null)) {
572                 this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
573             }
574             if ((this.onEndGetDataDelegate == null)) {
575                 this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
576             }
577             if ((this.onGetDataCompletedDelegate == null)) {
578                 this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
579             }
580             base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
581         }
582         
583         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
584         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
585             return base.Channel.BeginGetCollectionData(callback, asyncState);
586         }
587         
588         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
589         System.Collections.ObjectModel.ObservableCollection<object> WebServiceMoonlightTest.ServiceReference2.IService1.EndGetCollectionData(System.IAsyncResult result) {
590             return base.Channel.EndGetCollectionData(result);
591         }
592         
593         private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
594             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetCollectionData(callback, asyncState);
595         }
596         
597         private object[] OnEndGetCollectionData(System.IAsyncResult result) {
598             System.Collections.ObjectModel.ObservableCollection<object> retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetCollectionData(result);
599             return new object[] {
600                     retVal};
601         }
602         
603         private void OnGetCollectionDataCompleted(object state) {
604             if ((this.GetCollectionDataCompleted != null)) {
605                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
606                 this.GetCollectionDataCompleted(this, new GetCollectionDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
607             }
608         }
609         
610         public void GetCollectionDataAsync() {
611             this.GetCollectionDataAsync(null);
612         }
613         
614         public void GetCollectionDataAsync(object userState) {
615             if ((this.onBeginGetCollectionDataDelegate == null)) {
616                 this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
617             }
618             if ((this.onEndGetCollectionDataDelegate == null)) {
619                 this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
620             }
621             if ((this.onGetCollectionDataCompletedDelegate == null)) {
622                 this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
623             }
624             base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
625         }
626         
627         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
628         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
629             return base.Channel.BeginGetNestedData(callback, asyncState);
630         }
631         
632         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
633         WebServiceMoonlightTest.ServiceReference2.DataType2 WebServiceMoonlightTest.ServiceReference2.IService1.EndGetNestedData(System.IAsyncResult result) {
634             return base.Channel.EndGetNestedData(result);
635         }
636         
637         private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
638             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetNestedData(callback, asyncState);
639         }
640         
641         private object[] OnEndGetNestedData(System.IAsyncResult result) {
642             WebServiceMoonlightTest.ServiceReference2.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetNestedData(result);
643             return new object[] {
644                     retVal};
645         }
646         
647         private void OnGetNestedDataCompleted(object state) {
648             if ((this.GetNestedDataCompleted != null)) {
649                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
650                 this.GetNestedDataCompleted(this, new GetNestedDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
651             }
652         }
653         
654         public void GetNestedDataAsync() {
655             this.GetNestedDataAsync(null);
656         }
657         
658         public void GetNestedDataAsync(object userState) {
659             if ((this.onBeginGetNestedDataDelegate == null)) {
660                 this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
661             }
662             if ((this.onEndGetNestedDataDelegate == null)) {
663                 this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
664             }
665             if ((this.onGetNestedDataCompletedDelegate == null)) {
666                 this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
667             }
668             base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
669         }
670         
671         private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
672             return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
673         }
674         
675         private object[] OnEndOpen(System.IAsyncResult result) {
676             ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
677             return null;
678         }
679         
680         private void OnOpenCompleted(object state) {
681             if ((this.OpenCompleted != null)) {
682                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
683                 this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
684             }
685         }
686         
687         public void OpenAsync() {
688             this.OpenAsync(null);
689         }
690         
691         public void OpenAsync(object userState) {
692             if ((this.onBeginOpenDelegate == null)) {
693                 this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
694             }
695             if ((this.onEndOpenDelegate == null)) {
696                 this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
697             }
698             if ((this.onOpenCompletedDelegate == null)) {
699                 this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
700             }
701             base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
702         }
703         
704         private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
705             return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
706         }
707         
708         private object[] OnEndClose(System.IAsyncResult result) {
709             ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
710             return null;
711         }
712         
713         private void OnCloseCompleted(object state) {
714             if ((this.CloseCompleted != null)) {
715                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
716                 this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
717             }
718         }
719
720 #region JSMGetDatabases
721         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
722         System.IAsyncResult IService1.BeginJSMGetDatabases(JSMGetDatabasesRequest request, System.AsyncCallback callback, object asyncState)
723         {
724             return base.Channel.BeginJSMGetDatabases(request, callback, asyncState);
725         }
726
727         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
728         private System.IAsyncResult BeginJSMGetDatabases(System.AsyncCallback callback, object asyncState)
729         {
730             JSMGetDatabasesRequest inValue = new JSMGetDatabasesRequest();
731             return ((IService1)(this)).BeginJSMGetDatabases(inValue, callback, asyncState);
732         }
733
734         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
735         JSMGetDatabasesResponse IService1.EndJSMGetDatabases(System.IAsyncResult result)
736         {
737             return base.Channel.EndJSMGetDatabases(result);
738         }
739
740         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
741         private string EndJSMGetDatabases(System.IAsyncResult result)
742         {
743             JSMGetDatabasesResponse retVal = ((IService1)(this)).EndJSMGetDatabases(result);
744             return retVal.JSMGetDatabasesResult;
745         }
746
747         private System.IAsyncResult OnBeginJSMGetDatabases(object[] inValues, System.AsyncCallback callback, object asyncState)
748         {
749             return this.BeginJSMGetDatabases(callback, asyncState);
750         }
751
752         private object[] OnEndJSMGetDatabases(System.IAsyncResult result)
753         {
754             string retVal = this.EndJSMGetDatabases(result);
755             return new object[] {
756                 retVal};
757         }
758
759         private void OnJSMGetDatabasesCompleted(object state)
760         {
761             if ((this.JSMGetDatabasesCompleted != null))
762             {
763                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
764                 this.JSMGetDatabasesCompleted(this, new JSMGetDatabasesCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
765             }
766         }
767
768         public void JSMGetDatabasesAsync()
769         {
770             this.JSMGetDatabasesAsync(null);
771         }
772
773         public void JSMGetDatabasesAsync(object userState)
774         {
775             if ((this.onBeginJSMGetDatabasesDelegate == null))
776             {
777                 this.onBeginJSMGetDatabasesDelegate = new BeginOperationDelegate(this.OnBeginJSMGetDatabases);
778             }
779             if ((this.onEndJSMGetDatabasesDelegate == null))
780             {
781                 this.onEndJSMGetDatabasesDelegate = new EndOperationDelegate(this.OnEndJSMGetDatabases);
782             }
783             if ((this.onJSMGetDatabasesCompletedDelegate == null))
784             {
785                 this.onJSMGetDatabasesCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnJSMGetDatabasesCompleted);
786             }
787             base.InvokeAsync(this.onBeginJSMGetDatabasesDelegate, null, this.onEndJSMGetDatabasesDelegate, this.onJSMGetDatabasesCompletedDelegate, userState);
788         }
789 #endregion
790         
791         public void CloseAsync() {
792             this.CloseAsync(null);
793         }
794         
795         public void CloseAsync(object userState) {
796             if ((this.onBeginCloseDelegate == null)) {
797                 this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
798             }
799             if ((this.onEndCloseDelegate == null)) {
800                 this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
801             }
802             if ((this.onCloseCompletedDelegate == null)) {
803                 this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
804             }
805             base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
806         }
807         
808 /*
809         protected override WebServiceMoonlightTest.ServiceReference2.IService1 CreateChannel() {
810             return new Service1ClientChannel(this);
811         }
812         
813         private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
814             
815             public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1> client) : 
816                     base(client) {
817             }
818             
819             public System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState) {
820                 object[] _args = new object[0];
821                 System.IAsyncResult _result = base.BeginInvoke("GetData", _args, callback, asyncState);
822                 return _result;
823             }
824             
825             public object EndGetData(System.IAsyncResult result) {
826                 object[] _args = new object[0];
827                 object _result = ((object)(base.EndInvoke("GetData", _args, result)));
828                 return _result;
829             }
830             
831             public System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
832                 object[] _args = new object[0];
833                 System.IAsyncResult _result = base.BeginInvoke("GetCollectionData", _args, callback, asyncState);
834                 return _result;
835             }
836             
837             public System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result) {
838                 object[] _args = new object[0];
839                 System.Collections.ObjectModel.ObservableCollection<object> _result = ((System.Collections.ObjectModel.ObservableCollection<object>)(base.EndInvoke("GetCollectionData", _args, result)));
840                 return _result;
841             }
842             
843             public System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
844                 object[] _args = new object[0];
845                 System.IAsyncResult _result = base.BeginInvoke("GetNestedData", _args, callback, asyncState);
846                 return _result;
847             }
848             
849             public WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result) {
850                 object[] _args = new object[0];
851                 WebServiceMoonlightTest.ServiceReference2.DataType2 _result = ((WebServiceMoonlightTest.ServiceReference2.DataType2)(base.EndInvoke("GetNestedData", _args, result)));
852                 return _result;
853             }
854         }
855 */
856     }
857 }
858