Bug652331_2Test.cs 30 KB

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