7d592cc9761be9ea96d0e8c38b6f7c95ecfbe2ac
[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                 public void Bug652331_3 ()
47                 {
48                         // Init service
49                         ServiceHost serviceHost = new ServiceHost(typeof(Service1), new Uri("http://localhost:37564/Service1"));
50                         serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), string.Empty);
51
52                         // Enable metadata exchange (WSDL publishing)
53                         ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
54                         mexBehavior.HttpGetEnabled = true;
55                         serviceHost.Description.Behaviors.Add(mexBehavior);
56                         serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
57
58                         serviceHost.Open();
59
60                         try {
61                                 RunClient ();
62                         } finally {
63                                 serviceHost.Close ();
64                         }
65                 }
66
67                 void RunClient ()
68                 {
69                         var binding = new BasicHttpBinding ();
70                         var remoteAddress = new EndpointAddress ("http://localhost:37564/Service1");
71
72                         var normalClient      = new Service1Client (binding, remoteAddress);
73                         var collectionClient  = new Service1Client (binding, remoteAddress);
74                         var nestedClient      = new Service1Client (binding, remoteAddress);
75
76                         var waits = new ManualResetEvent [3];
77                         for (int i = 0; i < waits.Length; i++)
78                                 waits [i] = new ManualResetEvent (false);
79
80                         normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
81                                 if (e.Error != null) {
82                                         Assert.Fail ("Normal failed; error: {0}", e.Error);
83                                         throw e.Error;
84                                 }
85                                 Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal");
86                                 waits [0].Set ();
87                         };
88                         normalClient.GetDataAsync ();
89
90                         collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
91                                 if (e.Error != null) {
92                                         Assert.Fail ("Collection failed; error: {0}", e.Error);
93                                         throw e.Error;
94                                 }
95                                 Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection");
96                                 waits [1].Set ();
97                         };
98                         collectionClient.GetCollectionDataAsync ();
99
100                         nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
101                                 if (e.Error != null) {
102                                         Assert.Fail ("Nested failed; error: {0}", e.Error);
103                                         throw e.Error;
104                                 }
105                                 Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested");
106                                 waits [2].Set ();
107                         };
108                         nestedClient.GetNestedDataAsync ();
109
110                         WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1));
111                 }
112
113                 string ItemsToString (IEnumerable<DataType1> items)
114                 {
115                         return items.Aggregate ((string) null, (result, item) => result == null ? item.Id : result + "," + item.Id);
116                 }
117         }
118
119         public class Service1 : IService1
120         {
121                 public object GetData()
122                 {
123                         return new DataType1 { Id = "A" };
124                 }
125
126                 Func<object> gd;
127                 public IAsyncResult BeginGetData(AsyncCallback cb, object st)
128                 {
129                         gd = new Func<object> (GetData);
130                         return gd.BeginInvoke (cb, st);
131                 }
132
133                 public object EndGetData (IAsyncResult result)
134                 {
135                         return gd.EndInvoke (result);
136                 }
137
138                 public ObservableCollection<object> GetCollectionData()
139                 {
140                         return new ObservableCollection<object> { new DataType1 { Id = "B" }, new DataType1 { Id = "C" } };
141                 }
142
143                 Func<ObservableCollection<object>> gcd;
144                 public IAsyncResult BeginGetCollectionData(AsyncCallback cb, object st)
145                 {
146                         gcd = new Func<ObservableCollection<object>> (GetCollectionData);
147                         return gcd.BeginInvoke (cb, st);
148                 }
149
150                 public ObservableCollection<object> EndGetCollectionData (IAsyncResult result)
151                 {
152                         return gcd.EndInvoke (result);
153                 }
154
155                 public DataType2 GetNestedData()
156                 {
157                         return new DataType2 { Items = new ObservableCollection<object> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
158                 }
159
160                 Func<DataType2> gnd;
161                 public IAsyncResult BeginGetNestedData(AsyncCallback cb, object st)
162                 {
163                         gnd = new Func<DataType2> (GetNestedData);
164                         return gnd.BeginInvoke (cb, st);
165                 }
166
167                 public DataType2 EndGetNestedData (IAsyncResult result)
168                 {
169                         return gnd.EndInvoke (result);
170                 }
171         }
172 }
173
174
175 //------------------------------------------------------------------------------
176 // <auto-generated>
177 //     This code was generated by a tool.
178 //     Runtime Version:4.0.30319.372
179 //
180 //     Changes to this file may cause incorrect behavior and will be lost if
181 //     the code is regenerated.
182 // </auto-generated>
183 //------------------------------------------------------------------------------
184
185 // 
186 // This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
187 // 
188 namespace WebServiceMoonlightTest.ServiceReference2 {
189     using System.Runtime.Serialization;
190     
191     
192     [System.Diagnostics.DebuggerStepThroughAttribute()]
193     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
194     [System.Runtime.Serialization.DataContractAttribute(Name="DataType1", Namespace="http://mynamespace")]
195     public partial class DataType1 : object, System.ComponentModel.INotifyPropertyChanged {
196         
197         private string IdField;
198         
199         [System.Runtime.Serialization.DataMemberAttribute()]
200         public string Id {
201             get {
202                 return this.IdField;
203             }
204             set {
205                 if ((object.ReferenceEquals(this.IdField, value) != true)) {
206                     this.IdField = value;
207                     this.RaisePropertyChanged("Id");
208                 }
209             }
210         }
211         
212         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
213         
214         protected void RaisePropertyChanged(string propertyName) {
215             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
216             if ((propertyChanged != null)) {
217                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
218             }
219         }
220     }
221     
222     [System.Diagnostics.DebuggerStepThroughAttribute()]
223     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
224     [System.Runtime.Serialization.DataContractAttribute(Name="DataType2", Namespace="http://mynamespace")]
225     [System.Runtime.Serialization.KnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
226     [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
227     public partial class DataType2 : object, System.ComponentModel.INotifyPropertyChanged {
228         
229         private System.Collections.ObjectModel.ObservableCollection<object> ItemsField;
230         
231         [System.Runtime.Serialization.DataMemberAttribute()]
232         public System.Collections.ObjectModel.ObservableCollection<object> Items {
233             get {
234                 return this.ItemsField;
235             }
236             set {
237                 if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
238                     this.ItemsField = value;
239                     this.RaisePropertyChanged("Items");
240                 }
241             }
242         }
243         
244         public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
245         
246         protected void RaisePropertyChanged(string propertyName) {
247             System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
248             if ((propertyChanged != null)) {
249                 propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
250             }
251         }
252     }
253     
254     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
255     [System.ServiceModel.ServiceContractAttribute(Namespace="http://mynamespace", ConfigurationName="ServiceReference1.IService1")]
256     public interface IService1 {
257         
258         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetData", ReplyAction="http://mynamespace/IService1/GetDataResponse")]
259         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
260         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
261         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
262         System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState);
263         
264         object EndGetData(System.IAsyncResult result);
265         
266         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetCollectionData", ReplyAction="http://mynamespace/IService1/GetCollectionDataResponse")]
267         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
268         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
269         [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
270         System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState);
271         
272         System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result);
273         
274         [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetNestedData", ReplyAction="http://mynamespace/IService1/GetNestedDataResponse")]
275         System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState);
276         
277         WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result);
278     }
279     
280     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
281     public interface IService1Channel : WebServiceMoonlightTest.ServiceReference2.IService1, System.ServiceModel.IClientChannel {
282     }
283     
284     [System.Diagnostics.DebuggerStepThroughAttribute()]
285     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
286     public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
287         
288         private object[] results;
289         
290         public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
291                 base(exception, cancelled, userState) {
292             this.results = results;
293         }
294         
295         public object Result {
296             get {
297                 base.RaiseExceptionIfNecessary();
298                 return ((object)(this.results[0]));
299             }
300         }
301     }
302     
303     [System.Diagnostics.DebuggerStepThroughAttribute()]
304     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
305     public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
306         
307         private object[] results;
308         
309         public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
310                 base(exception, cancelled, userState) {
311             this.results = results;
312         }
313         
314         public System.Collections.ObjectModel.ObservableCollection<object> Result {
315             get {
316                 base.RaiseExceptionIfNecessary();
317                 return ((System.Collections.ObjectModel.ObservableCollection<object>)(this.results[0]));
318             }
319         }
320     }
321     
322     [System.Diagnostics.DebuggerStepThroughAttribute()]
323     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
324     public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
325         
326         private object[] results;
327         
328         public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
329                 base(exception, cancelled, userState) {
330             this.results = results;
331         }
332         
333         public WebServiceMoonlightTest.ServiceReference2.DataType2 Result {
334             get {
335                 base.RaiseExceptionIfNecessary();
336                 return ((WebServiceMoonlightTest.ServiceReference2.DataType2)(this.results[0]));
337             }
338         }
339     }
340     
341     [System.Diagnostics.DebuggerStepThroughAttribute()]
342     [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
343     public partial class Service1Client : System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
344         
345         private BeginOperationDelegate onBeginGetDataDelegate;
346         
347         private EndOperationDelegate onEndGetDataDelegate;
348         
349         private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
350         
351         private BeginOperationDelegate onBeginGetCollectionDataDelegate;
352         
353         private EndOperationDelegate onEndGetCollectionDataDelegate;
354         
355         private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
356         
357         private BeginOperationDelegate onBeginGetNestedDataDelegate;
358         
359         private EndOperationDelegate onEndGetNestedDataDelegate;
360         
361         private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
362         
363         private BeginOperationDelegate onBeginOpenDelegate;
364         
365         private EndOperationDelegate onEndOpenDelegate;
366         
367         private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
368         
369         private BeginOperationDelegate onBeginCloseDelegate;
370         
371         private EndOperationDelegate onEndCloseDelegate;
372         
373         private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
374         
375         public Service1Client() {
376         }
377         
378         public Service1Client(string endpointConfigurationName) : 
379                 base(endpointConfigurationName) {
380         }
381         
382         public Service1Client(string endpointConfigurationName, string remoteAddress) : 
383                 base(endpointConfigurationName, remoteAddress) {
384         }
385         
386         public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
387                 base(endpointConfigurationName, remoteAddress) {
388         }
389         
390         public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
391                 base(binding, remoteAddress) {
392         }
393         
394 /*
395         public System.Net.CookieContainer CookieContainer {
396             get {
397                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
398                 if ((httpCookieContainerManager != null)) {
399                     return httpCookieContainerManager.CookieContainer;
400                 }
401                 else {
402                     return null;
403                 }
404             }
405             set {
406                 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
407                 if ((httpCookieContainerManager != null)) {
408                     httpCookieContainerManager.CookieContainer = value;
409                 }
410                 else {
411                     throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
412                             "ookieContainerBindingElement.");
413                 }
414             }
415         }
416 */
417         
418         public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
419         
420         public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
421         
422         public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
423         
424         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
425         
426         public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
427         
428         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
429         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetData(System.AsyncCallback callback, object asyncState) {
430             return base.Channel.BeginGetData(callback, asyncState);
431         }
432         
433         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
434         object WebServiceMoonlightTest.ServiceReference2.IService1.EndGetData(System.IAsyncResult result) {
435             return base.Channel.EndGetData(result);
436         }
437         
438         private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
439             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetData(callback, asyncState);
440         }
441         
442         private object[] OnEndGetData(System.IAsyncResult result) {
443             object retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetData(result);
444             return new object[] {
445                     retVal};
446         }
447         
448         private void OnGetDataCompleted(object state) {
449             if ((this.GetDataCompleted != null)) {
450                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
451                 this.GetDataCompleted(this, new GetDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
452             }
453         }
454         
455         public void GetDataAsync() {
456             this.GetDataAsync(null);
457         }
458         
459         public void GetDataAsync(object userState) {
460             if ((this.onBeginGetDataDelegate == null)) {
461                 this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
462             }
463             if ((this.onEndGetDataDelegate == null)) {
464                 this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
465             }
466             if ((this.onGetDataCompletedDelegate == null)) {
467                 this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
468             }
469             base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
470         }
471         
472         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
473         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
474             return base.Channel.BeginGetCollectionData(callback, asyncState);
475         }
476         
477         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
478         System.Collections.ObjectModel.ObservableCollection<object> WebServiceMoonlightTest.ServiceReference2.IService1.EndGetCollectionData(System.IAsyncResult result) {
479             return base.Channel.EndGetCollectionData(result);
480         }
481         
482         private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
483             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetCollectionData(callback, asyncState);
484         }
485         
486         private object[] OnEndGetCollectionData(System.IAsyncResult result) {
487             System.Collections.ObjectModel.ObservableCollection<object> retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetCollectionData(result);
488             return new object[] {
489                     retVal};
490         }
491         
492         private void OnGetCollectionDataCompleted(object state) {
493             if ((this.GetCollectionDataCompleted != null)) {
494                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
495                 this.GetCollectionDataCompleted(this, new GetCollectionDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
496             }
497         }
498         
499         public void GetCollectionDataAsync() {
500             this.GetCollectionDataAsync(null);
501         }
502         
503         public void GetCollectionDataAsync(object userState) {
504             if ((this.onBeginGetCollectionDataDelegate == null)) {
505                 this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
506             }
507             if ((this.onEndGetCollectionDataDelegate == null)) {
508                 this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
509             }
510             if ((this.onGetCollectionDataCompletedDelegate == null)) {
511                 this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
512             }
513             base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
514         }
515         
516         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
517         System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
518             return base.Channel.BeginGetNestedData(callback, asyncState);
519         }
520         
521         [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
522         WebServiceMoonlightTest.ServiceReference2.DataType2 WebServiceMoonlightTest.ServiceReference2.IService1.EndGetNestedData(System.IAsyncResult result) {
523             return base.Channel.EndGetNestedData(result);
524         }
525         
526         private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
527             return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetNestedData(callback, asyncState);
528         }
529         
530         private object[] OnEndGetNestedData(System.IAsyncResult result) {
531             WebServiceMoonlightTest.ServiceReference2.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetNestedData(result);
532             return new object[] {
533                     retVal};
534         }
535         
536         private void OnGetNestedDataCompleted(object state) {
537             if ((this.GetNestedDataCompleted != null)) {
538                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
539                 this.GetNestedDataCompleted(this, new GetNestedDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
540             }
541         }
542         
543         public void GetNestedDataAsync() {
544             this.GetNestedDataAsync(null);
545         }
546         
547         public void GetNestedDataAsync(object userState) {
548             if ((this.onBeginGetNestedDataDelegate == null)) {
549                 this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
550             }
551             if ((this.onEndGetNestedDataDelegate == null)) {
552                 this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
553             }
554             if ((this.onGetNestedDataCompletedDelegate == null)) {
555                 this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
556             }
557             base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
558         }
559         
560         private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
561             return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
562         }
563         
564         private object[] OnEndOpen(System.IAsyncResult result) {
565             ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
566             return null;
567         }
568         
569         private void OnOpenCompleted(object state) {
570             if ((this.OpenCompleted != null)) {
571                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
572                 this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
573             }
574         }
575         
576         public void OpenAsync() {
577             this.OpenAsync(null);
578         }
579         
580         public void OpenAsync(object userState) {
581             if ((this.onBeginOpenDelegate == null)) {
582                 this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
583             }
584             if ((this.onEndOpenDelegate == null)) {
585                 this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
586             }
587             if ((this.onOpenCompletedDelegate == null)) {
588                 this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
589             }
590             base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
591         }
592         
593         private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
594             return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
595         }
596         
597         private object[] OnEndClose(System.IAsyncResult result) {
598             ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
599             return null;
600         }
601         
602         private void OnCloseCompleted(object state) {
603             if ((this.CloseCompleted != null)) {
604                 InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
605                 this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
606             }
607         }
608         
609         public void CloseAsync() {
610             this.CloseAsync(null);
611         }
612         
613         public void CloseAsync(object userState) {
614             if ((this.onBeginCloseDelegate == null)) {
615                 this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
616             }
617             if ((this.onEndCloseDelegate == null)) {
618                 this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
619             }
620             if ((this.onCloseCompletedDelegate == null)) {
621                 this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
622             }
623             base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
624         }
625         
626 /*
627         protected override WebServiceMoonlightTest.ServiceReference2.IService1 CreateChannel() {
628             return new Service1ClientChannel(this);
629         }
630         
631         private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
632             
633             public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1> client) : 
634                     base(client) {
635             }
636             
637             public System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState) {
638                 object[] _args = new object[0];
639                 System.IAsyncResult _result = base.BeginInvoke("GetData", _args, callback, asyncState);
640                 return _result;
641             }
642             
643             public object EndGetData(System.IAsyncResult result) {
644                 object[] _args = new object[0];
645                 object _result = ((object)(base.EndInvoke("GetData", _args, result)));
646                 return _result;
647             }
648             
649             public System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
650                 object[] _args = new object[0];
651                 System.IAsyncResult _result = base.BeginInvoke("GetCollectionData", _args, callback, asyncState);
652                 return _result;
653             }
654             
655             public System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result) {
656                 object[] _args = new object[0];
657                 System.Collections.ObjectModel.ObservableCollection<object> _result = ((System.Collections.ObjectModel.ObservableCollection<object>)(base.EndInvoke("GetCollectionData", _args, result)));
658                 return _result;
659             }
660             
661             public System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
662                 object[] _args = new object[0];
663                 System.IAsyncResult _result = base.BeginInvoke("GetNestedData", _args, callback, asyncState);
664                 return _result;
665             }
666             
667             public WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result) {
668                 object[] _args = new object[0];
669                 WebServiceMoonlightTest.ServiceReference2.DataType2 _result = ((WebServiceMoonlightTest.ServiceReference2.DataType2)(base.EndInvoke("GetNestedData", _args, result)));
670                 return _result;
671             }
672         }
673 */
674     }
675 }
676
677 #endif