Bug652331_2Test.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. //
  2. // Authors:
  3. // David Straw
  4. // Atsushi Enomoto <[email protected]>
  5. //
  6. // Copyright (C) 2011 Novell, Inc. http://www.novell.com
  7. //
  8. // Permission is hereby granted, free of charge, to any person obtaining
  9. // a copy of this software and associated documentation files (the
  10. // "Software"), to deal in the Software without restriction, including
  11. // without limitation the rights to use, copy, modify, merge, publish,
  12. // distribute, sublicense, and/or sell copies of the Software, and to
  13. // permit persons to whom the Software is furnished to do so, subject to
  14. // the following conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  23. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26. //
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Collections.ObjectModel;
  30. using System.Linq;
  31. using System.Runtime.Serialization;
  32. using System.ServiceModel;
  33. using System.ServiceModel.Description;
  34. using System.Threading;
  35. using NUnit.Framework;
  36. using WebServiceMoonlightTest.ServiceReference2;
  37. namespace MonoTests.System.ServiceModel.Dispatcher
  38. {
  39. [TestFixture]
  40. public class Bug652331_2Test
  41. {
  42. [Test]
  43. public void Bug652331_3 ()
  44. {
  45. // Init service
  46. ServiceHost serviceHost = new ServiceHost(typeof(Service1), new Uri("http://localhost:37564/Service1"));
  47. serviceHost.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), string.Empty);
  48. // Enable metadata exchange (WSDL publishing)
  49. ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
  50. mexBehavior.HttpGetEnabled = true;
  51. serviceHost.Description.Behaviors.Add(mexBehavior);
  52. serviceHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
  53. serviceHost.Open();
  54. try {
  55. RunClient ();
  56. } finally {
  57. serviceHost.Close ();
  58. }
  59. }
  60. void RunClient ()
  61. {
  62. var binding = new BasicHttpBinding ();
  63. var remoteAddress = new EndpointAddress ("http://localhost:37564/Service1");
  64. var client = new Service1Client (binding, remoteAddress);
  65. var waits = new ManualResetEvent [3];
  66. for (int i = 0; i < waits.Length; i++)
  67. waits [i] = new ManualResetEvent (false);
  68. client.GetDataCompleted += delegate (object o, GetDataCompletedEventArgs e) {
  69. if (e.Error != null)
  70. throw e.Error;
  71. Assert.AreEqual ("A", ((DataType1) e.Result).Id, "Normal");
  72. waits [0].Set ();
  73. };
  74. client.GetDataAsync ();
  75. client.GetCollectionDataCompleted += delegate (object sender, GetCollectionDataCompletedEventArgs e) {
  76. if (e.Error != null)
  77. throw e.Error;
  78. Assert.AreEqual ("B,C", ItemsToString (e.Result.Cast<DataType1> ()), "Collection");
  79. waits [1].Set ();
  80. };
  81. client.GetCollectionDataAsync ();
  82. client.GetNestedDataCompleted += delegate (object sender, GetNestedDataCompletedEventArgs e) {
  83. if (e.Error != null)
  84. throw e.Error;
  85. Assert.AreEqual ("D,E", ItemsToString (e.Result.Items.Cast<DataType1> ()), "Nested");
  86. waits [2].Set ();
  87. };
  88. client.GetNestedDataAsync ();
  89. WaitHandle.WaitAll (waits.Cast<WaitHandle> ().ToArray (), TimeSpan.FromMinutes (1));
  90. }
  91. string ItemsToString (IEnumerable<DataType1> items)
  92. {
  93. return items.Aggregate ((string) null, (result, item) => result == null ? item.Id : result + "," + item.Id);
  94. }
  95. }
  96. public class Service1 : IService1
  97. {
  98. public object GetData()
  99. {
  100. return new DataType1 { Id = "A" };
  101. }
  102. Func<object> gd;
  103. public IAsyncResult BeginGetData(AsyncCallback cb, object st)
  104. {
  105. gd = new Func<object> (GetData);
  106. return gd.BeginInvoke (cb, st);
  107. }
  108. public object EndGetData (IAsyncResult result)
  109. {
  110. return gd.EndInvoke (result);
  111. }
  112. public ObservableCollection<object> GetCollectionData()
  113. {
  114. return new ObservableCollection<object> { new DataType1 { Id = "B" }, new DataType1 { Id = "C" } };
  115. }
  116. Func<ObservableCollection<object>> gcd;
  117. public IAsyncResult BeginGetCollectionData(AsyncCallback cb, object st)
  118. {
  119. gcd = new Func<ObservableCollection<object>> (GetCollectionData);
  120. return gcd.BeginInvoke (cb, st);
  121. }
  122. public ObservableCollection<object> EndGetCollectionData (IAsyncResult result)
  123. {
  124. return gcd.EndInvoke (result);
  125. }
  126. public DataType2 GetNestedData()
  127. {
  128. return new DataType2 { Items = new ObservableCollection<object> { new DataType1 { Id = "D" }, new DataType1 { Id = "E" } } };
  129. }
  130. Func<DataType2> gnd;
  131. public IAsyncResult BeginGetNestedData(AsyncCallback cb, object st)
  132. {
  133. gnd = new Func<DataType2> (GetNestedData);
  134. return gnd.BeginInvoke (cb, st);
  135. }
  136. public DataType2 EndGetNestedData (IAsyncResult result)
  137. {
  138. return gnd.EndInvoke (result);
  139. }
  140. }
  141. }
  142. //------------------------------------------------------------------------------
  143. // <auto-generated>
  144. // This code was generated by a tool.
  145. // Runtime Version:4.0.30319.372
  146. //
  147. // Changes to this file may cause incorrect behavior and will be lost if
  148. // the code is regenerated.
  149. // </auto-generated>
  150. //------------------------------------------------------------------------------
  151. //
  152. // This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 4.0.50826.0
  153. //
  154. namespace WebServiceMoonlightTest.ServiceReference2 {
  155. using System.Runtime.Serialization;
  156. [System.Diagnostics.DebuggerStepThroughAttribute()]
  157. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
  158. [System.Runtime.Serialization.DataContractAttribute(Name="DataType1", Namespace="http://mynamespace")]
  159. public partial class DataType1 : object, System.ComponentModel.INotifyPropertyChanged {
  160. private string IdField;
  161. [System.Runtime.Serialization.DataMemberAttribute()]
  162. public string Id {
  163. get {
  164. return this.IdField;
  165. }
  166. set {
  167. if ((object.ReferenceEquals(this.IdField, value) != true)) {
  168. this.IdField = value;
  169. this.RaisePropertyChanged("Id");
  170. }
  171. }
  172. }
  173. public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  174. protected void RaisePropertyChanged(string propertyName) {
  175. System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
  176. if ((propertyChanged != null)) {
  177. propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
  178. }
  179. }
  180. }
  181. [System.Diagnostics.DebuggerStepThroughAttribute()]
  182. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
  183. [System.Runtime.Serialization.DataContractAttribute(Name="DataType2", Namespace="http://mynamespace")]
  184. [System.Runtime.Serialization.KnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
  185. [System.Runtime.Serialization.KnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
  186. public partial class DataType2 : object, System.ComponentModel.INotifyPropertyChanged {
  187. private System.Collections.ObjectModel.ObservableCollection<object> ItemsField;
  188. [System.Runtime.Serialization.DataMemberAttribute()]
  189. public System.Collections.ObjectModel.ObservableCollection<object> Items {
  190. get {
  191. return this.ItemsField;
  192. }
  193. set {
  194. if ((object.ReferenceEquals(this.ItemsField, value) != true)) {
  195. this.ItemsField = value;
  196. this.RaisePropertyChanged("Items");
  197. }
  198. }
  199. }
  200. public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
  201. protected void RaisePropertyChanged(string propertyName) {
  202. System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
  203. if ((propertyChanged != null)) {
  204. propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
  205. }
  206. }
  207. }
  208. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  209. [System.ServiceModel.ServiceContractAttribute(Namespace="http://mynamespace", ConfigurationName="ServiceReference1.IService1")]
  210. public interface IService1 {
  211. [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetData", ReplyAction="http://mynamespace/IService1/GetDataResponse")]
  212. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
  213. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
  214. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
  215. System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState);
  216. object EndGetData(System.IAsyncResult result);
  217. [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetCollectionData", ReplyAction="http://mynamespace/IService1/GetCollectionDataResponse")]
  218. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType1))]
  219. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(WebServiceMoonlightTest.ServiceReference2.DataType2))]
  220. [System.ServiceModel.ServiceKnownTypeAttribute(typeof(System.Collections.ObjectModel.ObservableCollection<object>))]
  221. System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState);
  222. System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result);
  223. [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://mynamespace/IService1/GetNestedData", ReplyAction="http://mynamespace/IService1/GetNestedDataResponse")]
  224. System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState);
  225. WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result);
  226. }
  227. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  228. public interface IService1Channel : WebServiceMoonlightTest.ServiceReference2.IService1, System.ServiceModel.IClientChannel {
  229. }
  230. [System.Diagnostics.DebuggerStepThroughAttribute()]
  231. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  232. public partial class GetDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
  233. private object[] results;
  234. public GetDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
  235. base(exception, cancelled, userState) {
  236. this.results = results;
  237. }
  238. public object Result {
  239. get {
  240. base.RaiseExceptionIfNecessary();
  241. return ((object)(this.results[0]));
  242. }
  243. }
  244. }
  245. [System.Diagnostics.DebuggerStepThroughAttribute()]
  246. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  247. public partial class GetCollectionDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
  248. private object[] results;
  249. public GetCollectionDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
  250. base(exception, cancelled, userState) {
  251. this.results = results;
  252. }
  253. public System.Collections.ObjectModel.ObservableCollection<object> Result {
  254. get {
  255. base.RaiseExceptionIfNecessary();
  256. return ((System.Collections.ObjectModel.ObservableCollection<object>)(this.results[0]));
  257. }
  258. }
  259. }
  260. [System.Diagnostics.DebuggerStepThroughAttribute()]
  261. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  262. public partial class GetNestedDataCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
  263. private object[] results;
  264. public GetNestedDataCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
  265. base(exception, cancelled, userState) {
  266. this.results = results;
  267. }
  268. public WebServiceMoonlightTest.ServiceReference2.DataType2 Result {
  269. get {
  270. base.RaiseExceptionIfNecessary();
  271. return ((WebServiceMoonlightTest.ServiceReference2.DataType2)(this.results[0]));
  272. }
  273. }
  274. }
  275. [System.Diagnostics.DebuggerStepThroughAttribute()]
  276. [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
  277. public partial class Service1Client : System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
  278. private BeginOperationDelegate onBeginGetDataDelegate;
  279. private EndOperationDelegate onEndGetDataDelegate;
  280. private System.Threading.SendOrPostCallback onGetDataCompletedDelegate;
  281. private BeginOperationDelegate onBeginGetCollectionDataDelegate;
  282. private EndOperationDelegate onEndGetCollectionDataDelegate;
  283. private System.Threading.SendOrPostCallback onGetCollectionDataCompletedDelegate;
  284. private BeginOperationDelegate onBeginGetNestedDataDelegate;
  285. private EndOperationDelegate onEndGetNestedDataDelegate;
  286. private System.Threading.SendOrPostCallback onGetNestedDataCompletedDelegate;
  287. private BeginOperationDelegate onBeginOpenDelegate;
  288. private EndOperationDelegate onEndOpenDelegate;
  289. private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
  290. private BeginOperationDelegate onBeginCloseDelegate;
  291. private EndOperationDelegate onEndCloseDelegate;
  292. private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
  293. public Service1Client() {
  294. }
  295. public Service1Client(string endpointConfigurationName) :
  296. base(endpointConfigurationName) {
  297. }
  298. public Service1Client(string endpointConfigurationName, string remoteAddress) :
  299. base(endpointConfigurationName, remoteAddress) {
  300. }
  301. public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
  302. base(endpointConfigurationName, remoteAddress) {
  303. }
  304. public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
  305. base(binding, remoteAddress) {
  306. }
  307. /*
  308. public System.Net.CookieContainer CookieContainer {
  309. get {
  310. System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
  311. if ((httpCookieContainerManager != null)) {
  312. return httpCookieContainerManager.CookieContainer;
  313. }
  314. else {
  315. return null;
  316. }
  317. }
  318. set {
  319. System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
  320. if ((httpCookieContainerManager != null)) {
  321. httpCookieContainerManager.CookieContainer = value;
  322. }
  323. else {
  324. throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
  325. "ookieContainerBindingElement.");
  326. }
  327. }
  328. }
  329. */
  330. public event System.EventHandler<GetDataCompletedEventArgs> GetDataCompleted;
  331. public event System.EventHandler<GetCollectionDataCompletedEventArgs> GetCollectionDataCompleted;
  332. public event System.EventHandler<GetNestedDataCompletedEventArgs> GetNestedDataCompleted;
  333. public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
  334. public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
  335. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  336. System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetData(System.AsyncCallback callback, object asyncState) {
  337. return base.Channel.BeginGetData(callback, asyncState);
  338. }
  339. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  340. object WebServiceMoonlightTest.ServiceReference2.IService1.EndGetData(System.IAsyncResult result) {
  341. return base.Channel.EndGetData(result);
  342. }
  343. private System.IAsyncResult OnBeginGetData(object[] inValues, System.AsyncCallback callback, object asyncState) {
  344. return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetData(callback, asyncState);
  345. }
  346. private object[] OnEndGetData(System.IAsyncResult result) {
  347. object retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetData(result);
  348. return new object[] {
  349. retVal};
  350. }
  351. private void OnGetDataCompleted(object state) {
  352. if ((this.GetDataCompleted != null)) {
  353. InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
  354. this.GetDataCompleted(this, new GetDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
  355. }
  356. }
  357. public void GetDataAsync() {
  358. this.GetDataAsync(null);
  359. }
  360. public void GetDataAsync(object userState) {
  361. if ((this.onBeginGetDataDelegate == null)) {
  362. this.onBeginGetDataDelegate = new BeginOperationDelegate(this.OnBeginGetData);
  363. }
  364. if ((this.onEndGetDataDelegate == null)) {
  365. this.onEndGetDataDelegate = new EndOperationDelegate(this.OnEndGetData);
  366. }
  367. if ((this.onGetDataCompletedDelegate == null)) {
  368. this.onGetDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetDataCompleted);
  369. }
  370. base.InvokeAsync(this.onBeginGetDataDelegate, null, this.onEndGetDataDelegate, this.onGetDataCompletedDelegate, userState);
  371. }
  372. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  373. System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
  374. return base.Channel.BeginGetCollectionData(callback, asyncState);
  375. }
  376. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  377. System.Collections.ObjectModel.ObservableCollection<object> WebServiceMoonlightTest.ServiceReference2.IService1.EndGetCollectionData(System.IAsyncResult result) {
  378. return base.Channel.EndGetCollectionData(result);
  379. }
  380. private System.IAsyncResult OnBeginGetCollectionData(object[] inValues, System.AsyncCallback callback, object asyncState) {
  381. return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetCollectionData(callback, asyncState);
  382. }
  383. private object[] OnEndGetCollectionData(System.IAsyncResult result) {
  384. System.Collections.ObjectModel.ObservableCollection<object> retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetCollectionData(result);
  385. return new object[] {
  386. retVal};
  387. }
  388. private void OnGetCollectionDataCompleted(object state) {
  389. if ((this.GetCollectionDataCompleted != null)) {
  390. InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
  391. this.GetCollectionDataCompleted(this, new GetCollectionDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
  392. }
  393. }
  394. public void GetCollectionDataAsync() {
  395. this.GetCollectionDataAsync(null);
  396. }
  397. public void GetCollectionDataAsync(object userState) {
  398. if ((this.onBeginGetCollectionDataDelegate == null)) {
  399. this.onBeginGetCollectionDataDelegate = new BeginOperationDelegate(this.OnBeginGetCollectionData);
  400. }
  401. if ((this.onEndGetCollectionDataDelegate == null)) {
  402. this.onEndGetCollectionDataDelegate = new EndOperationDelegate(this.OnEndGetCollectionData);
  403. }
  404. if ((this.onGetCollectionDataCompletedDelegate == null)) {
  405. this.onGetCollectionDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCollectionDataCompleted);
  406. }
  407. base.InvokeAsync(this.onBeginGetCollectionDataDelegate, null, this.onEndGetCollectionDataDelegate, this.onGetCollectionDataCompletedDelegate, userState);
  408. }
  409. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  410. System.IAsyncResult WebServiceMoonlightTest.ServiceReference2.IService1.BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
  411. return base.Channel.BeginGetNestedData(callback, asyncState);
  412. }
  413. [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
  414. WebServiceMoonlightTest.ServiceReference2.DataType2 WebServiceMoonlightTest.ServiceReference2.IService1.EndGetNestedData(System.IAsyncResult result) {
  415. return base.Channel.EndGetNestedData(result);
  416. }
  417. private System.IAsyncResult OnBeginGetNestedData(object[] inValues, System.AsyncCallback callback, object asyncState) {
  418. return ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).BeginGetNestedData(callback, asyncState);
  419. }
  420. private object[] OnEndGetNestedData(System.IAsyncResult result) {
  421. WebServiceMoonlightTest.ServiceReference2.DataType2 retVal = ((WebServiceMoonlightTest.ServiceReference2.IService1)(this)).EndGetNestedData(result);
  422. return new object[] {
  423. retVal};
  424. }
  425. private void OnGetNestedDataCompleted(object state) {
  426. if ((this.GetNestedDataCompleted != null)) {
  427. InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
  428. this.GetNestedDataCompleted(this, new GetNestedDataCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
  429. }
  430. }
  431. public void GetNestedDataAsync() {
  432. this.GetNestedDataAsync(null);
  433. }
  434. public void GetNestedDataAsync(object userState) {
  435. if ((this.onBeginGetNestedDataDelegate == null)) {
  436. this.onBeginGetNestedDataDelegate = new BeginOperationDelegate(this.OnBeginGetNestedData);
  437. }
  438. if ((this.onEndGetNestedDataDelegate == null)) {
  439. this.onEndGetNestedDataDelegate = new EndOperationDelegate(this.OnEndGetNestedData);
  440. }
  441. if ((this.onGetNestedDataCompletedDelegate == null)) {
  442. this.onGetNestedDataCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetNestedDataCompleted);
  443. }
  444. base.InvokeAsync(this.onBeginGetNestedDataDelegate, null, this.onEndGetNestedDataDelegate, this.onGetNestedDataCompletedDelegate, userState);
  445. }
  446. private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
  447. return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
  448. }
  449. private object[] OnEndOpen(System.IAsyncResult result) {
  450. ((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
  451. return null;
  452. }
  453. private void OnOpenCompleted(object state) {
  454. if ((this.OpenCompleted != null)) {
  455. InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
  456. this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
  457. }
  458. }
  459. public void OpenAsync() {
  460. this.OpenAsync(null);
  461. }
  462. public void OpenAsync(object userState) {
  463. if ((this.onBeginOpenDelegate == null)) {
  464. this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
  465. }
  466. if ((this.onEndOpenDelegate == null)) {
  467. this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
  468. }
  469. if ((this.onOpenCompletedDelegate == null)) {
  470. this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
  471. }
  472. base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
  473. }
  474. private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
  475. return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
  476. }
  477. private object[] OnEndClose(System.IAsyncResult result) {
  478. ((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
  479. return null;
  480. }
  481. private void OnCloseCompleted(object state) {
  482. if ((this.CloseCompleted != null)) {
  483. InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
  484. this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
  485. }
  486. }
  487. public void CloseAsync() {
  488. this.CloseAsync(null);
  489. }
  490. public void CloseAsync(object userState) {
  491. if ((this.onBeginCloseDelegate == null)) {
  492. this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
  493. }
  494. if ((this.onEndCloseDelegate == null)) {
  495. this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
  496. }
  497. if ((this.onCloseCompletedDelegate == null)) {
  498. this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
  499. }
  500. base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
  501. }
  502. /*
  503. protected override WebServiceMoonlightTest.ServiceReference2.IService1 CreateChannel() {
  504. return new Service1ClientChannel(this);
  505. }
  506. private class Service1ClientChannel : ChannelBase<WebServiceMoonlightTest.ServiceReference2.IService1>, WebServiceMoonlightTest.ServiceReference2.IService1 {
  507. public Service1ClientChannel(System.ServiceModel.ClientBase<WebServiceMoonlightTest.ServiceReference2.IService1> client) :
  508. base(client) {
  509. }
  510. public System.IAsyncResult BeginGetData(System.AsyncCallback callback, object asyncState) {
  511. object[] _args = new object[0];
  512. System.IAsyncResult _result = base.BeginInvoke("GetData", _args, callback, asyncState);
  513. return _result;
  514. }
  515. public object EndGetData(System.IAsyncResult result) {
  516. object[] _args = new object[0];
  517. object _result = ((object)(base.EndInvoke("GetData", _args, result)));
  518. return _result;
  519. }
  520. public System.IAsyncResult BeginGetCollectionData(System.AsyncCallback callback, object asyncState) {
  521. object[] _args = new object[0];
  522. System.IAsyncResult _result = base.BeginInvoke("GetCollectionData", _args, callback, asyncState);
  523. return _result;
  524. }
  525. public System.Collections.ObjectModel.ObservableCollection<object> EndGetCollectionData(System.IAsyncResult result) {
  526. object[] _args = new object[0];
  527. System.Collections.ObjectModel.ObservableCollection<object> _result = ((System.Collections.ObjectModel.ObservableCollection<object>)(base.EndInvoke("GetCollectionData", _args, result)));
  528. return _result;
  529. }
  530. public System.IAsyncResult BeginGetNestedData(System.AsyncCallback callback, object asyncState) {
  531. object[] _args = new object[0];
  532. System.IAsyncResult _result = base.BeginInvoke("GetNestedData", _args, callback, asyncState);
  533. return _result;
  534. }
  535. public WebServiceMoonlightTest.ServiceReference2.DataType2 EndGetNestedData(System.IAsyncResult result) {
  536. object[] _args = new object[0];
  537. WebServiceMoonlightTest.ServiceReference2.DataType2 _result = ((WebServiceMoonlightTest.ServiceReference2.DataType2)(base.EndInvoke("GetNestedData", _args, result)));
  538. return _result;
  539. }
  540. }
  541. */
  542. }
  543. }