comparison Source/ServiceModel/LinqServiceClient.Silverlight.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.ServiceModel;
3
4 namespace BLToolkit.ServiceModel
5 {
6 class LinqServiceClient : ClientBase<Async.ILinqService>, ILinqService, IDisposable
7 {
8 #region Init
9
10 public LinqServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { }
11 public LinqServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { }
12 public LinqServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) : base(endpointConfigurationName, remoteAddress) { }
13 public LinqServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress) { }
14
15 #endregion
16
17 #region ILinqService Members
18
19 public string GetSqlProviderType()
20 {
21 var async = Channel.BeginGetSqlProviderType(null, null);
22 return Channel.EndGetSqlProviderType(async);
23 }
24
25 public int ExecuteNonQuery(string queryData)
26 {
27 var async = Channel.BeginExecuteNonQuery(queryData, null, null);
28 return Channel.EndExecuteNonQuery(async);
29 }
30
31 public object ExecuteScalar(string queryData)
32 {
33 var async = Channel.BeginExecuteScalar(queryData, null, null);
34 return Channel.EndExecuteScalar(async);
35 }
36
37 public string ExecuteReader(string queryData)
38 {
39 var async = Channel.BeginExecuteReader(queryData, null, null);
40 return Channel.EndExecuteReader(async);
41 }
42
43 public int ExecuteBatch(string queryData)
44 {
45 var async = Channel.BeginExecuteBatch(queryData, null, null);
46 return Channel.EndExecuteBatch(async);
47 }
48
49 #endregion
50
51 #region IDisposable Members
52
53 void IDisposable.Dispose()
54 {
55 try
56 {
57 if (State != CommunicationState.Faulted)
58 ((ICommunicationObject)this).Close();
59 else
60 Abort();
61 }
62 catch (CommunicationException)
63 {
64 Abort();
65 }
66 catch (TimeoutException)
67 {
68 Abort();
69 }
70 catch (Exception)
71 {
72 Abort();
73 throw;
74 }
75 }
76
77 #endregion
78
79 #region Overrides
80
81 protected override Async.ILinqService CreateChannel()
82 {
83 return new LinqServiceClientChannel(this);
84 }
85
86 #endregion
87
88 #region Channel
89
90 class LinqServiceClientChannel : ChannelBase<Async.ILinqService>, Async.ILinqService
91 {
92 public LinqServiceClientChannel(ClientBase<Async.ILinqService> client) :
93 base(client)
94 {
95 }
96
97 public IAsyncResult BeginGetSqlProviderType(AsyncCallback callback, object asyncState)
98 {
99 return BeginInvoke("GetSqlProviderType", new object[0], callback, asyncState);
100 }
101
102 public string EndGetSqlProviderType(IAsyncResult result)
103 {
104 return (string)EndInvoke("GetSqlProviderType", new object[0], result);
105 }
106
107 public IAsyncResult BeginExecuteNonQuery(string queryData, AsyncCallback callback, object asyncState)
108 {
109 return BeginInvoke("ExecuteNonQuery", new object[] { queryData }, callback, asyncState);
110 }
111
112 public int EndExecuteNonQuery(IAsyncResult result)
113 {
114 return (int)EndInvoke("ExecuteNonQuery", new object[0], result);
115 }
116
117 public IAsyncResult BeginExecuteScalar(string queryData, AsyncCallback callback, object asyncState)
118 {
119 return BeginInvoke("ExecuteScalar", new object[] { queryData }, callback, asyncState);
120 }
121
122 public object EndExecuteScalar(IAsyncResult result)
123 {
124 return EndInvoke("ExecuteScalar", new object[0], result);
125 }
126
127 public IAsyncResult BeginExecuteReader(string queryData, AsyncCallback callback, object asyncState)
128 {
129 return BeginInvoke("ExecuteReader", new object[] { queryData }, callback, asyncState);
130 }
131
132 public string EndExecuteReader(IAsyncResult result)
133 {
134 return (string)EndInvoke("ExecuteReader", new object[0], result);
135 }
136
137 public IAsyncResult BeginExecuteBatch(string queryData, AsyncCallback callback, object asyncState)
138 {
139 return BeginInvoke("ExecuteBatch", new object[] { queryData }, callback, asyncState);
140 }
141
142 public int EndExecuteBatch(IAsyncResult result)
143 {
144 return (int)EndInvoke("ExecuteBatch", new object[0], result);
145 }
146 }
147
148 #endregion
149 }
150 }