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