5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2011 Novell, Inc. http://www.novell.com
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
32 using System.Runtime.Serialization;
33 using System.ServiceModel;
34 using System.ServiceModel.Description;
35 using System.Threading;
36 using NUnit.Framework;
38 using WebServiceMoonlightTest.ServiceReference2;
40 namespace MonoTests.System.ServiceModel.Dispatcher
43 public class Bug652331_2Test
46 public void Bug652331_3 ()
49 ServiceHost serviceHost = new ServiceHost(typeof(Service1), new Uri("http://localhost:37564/Service1"));
50 serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), string.Empty);
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");
69 var binding = new BasicHttpBinding ();
70 var remoteAddress = new EndpointAddress ("http://localhost:37564/Service1");
72 var normalClient = new Service1Client (binding, remoteAddress);
73 var collectionClient = new Service1Client (binding, remoteAddress);
74 var nestedClient = new Service1Client (binding, remoteAddress);
76 var waits = new ManualResetEvent [3];
77 for (int i = 0; i < waits.Length; i++)
78 waits [i] = new ManualResetEvent (false);
80 normalClient.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
81 if (e.Error != null) {
82 Assert.Fail ("Normal failed; error: {0}", e.Error);
85 Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal");
88 normalClient.GetDataAsync ();
90 collectionClient.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
91 if (e.Error != null) {
92 Assert.Fail ("Collection failed; error: {0}", e.Error);
95 Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection");
98 collectionClient.GetCollectionDataAsync ();
100 nestedClient.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
101 if (e.Error != null) {
102 Assert.Fail ("Nested failed; error: {0}", e.Error);
105 Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested");
108 nestedClient.GetNestedDataAsync ();
110 WaitHandle.WaitAll (waits, TimeSpan.FromMinutes (1));
113 string ItemsToString (IEnumerable<DataType1> items)
115 return items.Aggregate ((string) null, (result, item) => result == null ? item.Id : result + "," + item.Id);
119 public class Service1 : IService1
121 public object GetData()
123 return new DataType1 { Id = "A" };
127 public IAsyncResult BeginGetData(AsyncCallback cb, object st)
129 gd = new Func<object> (GetData);
130 return gd.BeginInvoke (cb, st);
133 public object EndGetData (IAsyncResult result)
135 return gd.EndInvoke (result);
138 public ObservableCollection<object> GetCollectionData()
140 return new ObservableCollection<object> { new DataType1 { Id = "B" }, new DataType1 { Id = "C" } };
143 Func<ObservableCollection<object>> gcd;
144 public IAsyncResult BeginGetCollectionData(AsyncCallback cb, object st)
146 gcd = new Func<ObservableCollection<object>> (GetCollectionData);
147 return gcd.BeginInvoke (cb, st);
150 public ObservableCollection<object> EndGetCollectionData (IAsyncResult result)
152 return gcd.EndInvoke (result);
155 public DataType2 GetNestedData()
157 return new DataType2 { Items = new ObservableCollection<object> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
161 public IAsyncResult BeginGetNestedData(AsyncCallback cb, object st)
163 gnd = new Func<DataType2> (GetNestedData);
164 return gnd.BeginInvoke (cb, st);
167 public DataType2 EndGetNestedData (IAsyncResult result)
169 return gnd.EndInvoke (result);
175 //------------------------------------------------------------------------------
177 // This code was generated by a tool.
178 // Runtime Version:4.0.30319.372
180 // Changes to this file may cause incorrect behavior and will be lost if
181 // the code is regenerated.
183 //------------------------------------------------------------------------------
186 // This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
188 namespace WebServiceMoonlightTest.ServiceReference2 {
189 using System.Runtime.Serialization;
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 {
197 private string IdField;
199 [System.Runtime.Serialization.DataMemberAttribute()]
205 if ((object.ReferenceEquals(this.IdField, value) != true)) {
206 this.IdField = value;
207 this.RaisePropertyChanged("Id");
212 public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
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));
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 {
229 private System.Collections.ObjectModel.ObservableCollection<object> ItemsField;
231 [System.Runtime.Serialization.DataMemberAttribute()]
232 public System.Collections.ObjectModel.ObservableCollection<object> Items {
234 return this.ItemsField;
237 if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
238 this.ItemsField = value;
239 this.RaisePropertyChanged("Items");
244 public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
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));
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 {
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);
264 object EndGetData(System.IAsyncResult result);
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);
272 System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result);
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);
277 WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result);
280 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
281 public interface IService1Channel : WebServiceMoonlightTest.ServiceReference2.IService1, System.ServiceModel.IClientChannel {
284 [System.Diagnostics.DebuggerStepThroughAttribute()]
285 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
286 public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
288 private object[] results;
290 public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
291 base(exception, cancelled, userState) {
292 this.results = results;
295 public object Result {
297 base.RaiseExceptionIfNecessary();
298 return ((object)(this.results[0]));
303 [System.Diagnostics.DebuggerStepThroughAttribute()]
304 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
305 public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
307 private object[] results;
309 public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
310 base(exception, cancelled, userState) {
311 this.results = results;
314 public System.Collections.ObjectModel.ObservableCollection<object> Result {
316 base.RaiseExceptionIfNecessary();
317 return ((System.Collections.ObjectModel.ObservableCollection<object>)(this.results[0]));
322 [System.Diagnostics.DebuggerStepThroughAttribute()]
323 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
324 public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
326 private object[] results;
328 public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
329 base(exception, cancelled, userState) {
330 this.results = results;
333 public WebServiceMoonlightTest.ServiceReference2.DataType2 Result {
335 base.RaiseExceptionIfNecessary();
336 return ((WebServiceMoonlightTest.ServiceReference2.DataType2)(this.results[0]));
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 {
345 private BeginOperationDelegate onBeginGetDataDelegate;
347 private EndOperationDelegate onEndGetDataDelegate;
349 private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
351 private BeginOperationDelegate onBeginGetCollectionDataDelegate;
353 private EndOperationDelegate onEndGetCollectionDataDelegate;
355 private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
357 private BeginOperationDelegate onBeginGetNestedDataDelegate;
359 private EndOperationDelegate onEndGetNestedDataDelegate;
361 private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
363 private BeginOperationDelegate onBeginOpenDelegate;
365 private EndOperationDelegate onEndOpenDelegate;
367 private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
369 private BeginOperationDelegate onBeginCloseDelegate;
371 private EndOperationDelegate onEndCloseDelegate;
373 private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
375 public Service1Client() {
378 public Service1Client(string endpointConfigurationName) :
379 base(endpointConfigurationName) {
382 public Service1Client(string endpointConfigurationName, string remoteAddress) :
383 base(endpointConfigurationName, remoteAddress) {
386 public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
387 base(endpointConfigurationName, remoteAddress) {
390 public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
391 base(binding, remoteAddress) {
395 public System.Net.CookieContainer CookieContainer {
397 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
398 if ((httpCookieContainerManager != null)) {
399 return httpCookieContainerManager.CookieContainer;
406 System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
407 if ((httpCookieContainerManager != null)) {
408 httpCookieContainerManager.CookieContainer = value;
411 throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
412 "ookieContainerBindingElement.");
418 public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
420 public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
422 public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
424 public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
426 public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
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);
433 [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
434 object WebServiceMoonlightTest.ServiceReference2.IService1.EndGetData(System.IAsyncResult result) {
435 return base.Channel.EndGetData(result);
438 private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
439 return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetData(callback, asyncState);
442 private object[] OnEndGetData(System.IAsyncResult result) {
443 object retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetData(result);
444 return new object[] {
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));
455 public void GetDataAsync() {
456 this.GetDataAsync(null);
459 public void GetDataAsync(object userState) {
460 if ((this.onBeginGetDataDelegate == null)) {
461 this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
463 if ((this.onEndGetDataDelegate == null)) {
464 this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
466 if ((this.onGetDataCompletedDelegate == null)) {
467 this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
469 base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
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);
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);
482 private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
483 return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetCollectionData(callback, asyncState);
486 private object[] OnEndGetCollectionData(System.IAsyncResult result) {
487 System.Collections.ObjectModel.ObservableCollection<object> retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetCollectionData(result);
488 return new object[] {
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));
499 public void GetCollectionDataAsync() {
500 this.GetCollectionDataAsync(null);
503 public void GetCollectionDataAsync(object userState) {
504 if ((this.onBeginGetCollectionDataDelegate == null)) {
505 this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
507 if ((this.onEndGetCollectionDataDelegate == null)) {
508 this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
510 if ((this.onGetCollectionDataCompletedDelegate == null)) {
511 this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
513 base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
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);
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);
526 private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
527 return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetNestedData(callback, asyncState);
530 private object[] OnEndGetNestedData(System.IAsyncResult result) {
531 WebServiceMoonlightTest.ServiceReference2.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetNestedData(result);
532 return new object[] {
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));
543 public void GetNestedDataAsync() {
544 this.GetNestedDataAsync(null);
547 public void GetNestedDataAsync(object userState) {
548 if ((this.onBeginGetNestedDataDelegate == null)) {
549 this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
551 if ((this.onEndGetNestedDataDelegate == null)) {
552 this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
554 if ((this.onGetNestedDataCompletedDelegate == null)) {
555 this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
557 base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
560 private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
561 return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
564 private object[] OnEndOpen(System.IAsyncResult result) {
565 ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
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));
576 public void OpenAsync() {
577 this.OpenAsync(null);
580 public void OpenAsync(object userState) {
581 if ((this.onBeginOpenDelegate == null)) {
582 this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
584 if ((this.onEndOpenDelegate == null)) {
585 this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
587 if ((this.onOpenCompletedDelegate == null)) {
588 this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
590 base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
593 private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
594 return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
597 private object[] OnEndClose(System.IAsyncResult result) {
598 ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
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));
609 public void CloseAsync() {
610 this.CloseAsync(null);
613 public void CloseAsync(object userState) {
614 if ((this.onBeginCloseDelegate == null)) {
615 this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
617 if ((this.onEndCloseDelegate == null)) {
618 this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
620 if ((this.onCloseCompletedDelegate == null)) {
621 this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
623 base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
627 protected override WebServiceMoonlightTest.ServiceReference2.IService1 CreateChannel() {
628 return new Service1ClientChannel(this);
631 private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
633 public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1> client) :
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);
643 public object EndGetData(System.IAsyncResult result) {
644 object[] _args = new object[0];
645 object _result = ((object)(base.EndInvoke("GetData", _args, result)));
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);
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)));
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);
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)));