diff options
Diffstat (limited to 'src/bindings/mono/eldbus_mono/eldbus_proxy.cs')
-rw-r--r-- | src/bindings/mono/eldbus_mono/eldbus_proxy.cs | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs index 6b4c68e..a3a984d 100644 --- a/src/bindings/mono/eldbus_mono/eldbus_proxy.cs +++ b/src/bindings/mono/eldbus_mono/eldbus_proxy.cs | |||
@@ -1,3 +1,18 @@ | |||
1 | /* | ||
2 | * Copyright 2019 by its authors. See AUTHORS. | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
1 | #pragma warning disable 1591 | 16 | #pragma warning disable 1591 |
2 | 17 | ||
3 | using System; | 18 | using System; |
@@ -9,8 +24,8 @@ using static eldbus.EldbusProxyNativeFunctions; | |||
9 | namespace eldbus | 24 | namespace eldbus |
10 | { | 25 | { |
11 | 26 | ||
12 | [EditorBrowsable(EditorBrowsableState.Never)] | 27 | [EditorBrowsable(EditorBrowsableState.Never)] |
13 | public static class EldbusProxyNativeFunctions | 28 | internal static class EldbusProxyNativeFunctions |
14 | { | 29 | { |
15 | [DllImport(efl.Libs.Eldbus)] public static extern IntPtr | 30 | [DllImport(efl.Libs.Eldbus)] public static extern IntPtr |
16 | eldbus_proxy_get(IntPtr obj, string _interface); | 31 | eldbus_proxy_get(IntPtr obj, string _interface); |
@@ -200,7 +215,7 @@ public class Proxy : IDisposable | |||
200 | 215 | ||
201 | if (member == null) | 216 | if (member == null) |
202 | { | 217 | { |
203 | throw new ArgumentNullException("member"); | 218 | throw new ArgumentNullException(nameof(member)); |
204 | } | 219 | } |
205 | 220 | ||
206 | var ptr = eldbus_proxy_method_call_new(Handle, member); | 221 | var ptr = eldbus_proxy_method_call_new(Handle, member); |
@@ -218,9 +233,13 @@ public class Proxy : IDisposable | |||
218 | 233 | ||
219 | if (msg == null) | 234 | if (msg == null) |
220 | { | 235 | { |
221 | throw new ArgumentNullException("msg"); | 236 | throw new ArgumentNullException(nameof(msg)); |
222 | } | 237 | } |
223 | 238 | ||
239 | // Native send() takes ownership of the message. We ref here to keep the IDisposable | ||
240 | // behavior simpler and keeping the original object alive in case the user wants. | ||
241 | msg.Ref(); | ||
242 | |||
224 | IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr(); | 243 | IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr(); |
225 | IntPtr cb_data = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt); | 244 | IntPtr cb_data = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt); |
226 | 245 | ||
@@ -250,14 +269,15 @@ public class Proxy : IDisposable | |||
250 | { | 269 | { |
251 | CheckHandle(); | 270 | CheckHandle(); |
252 | 271 | ||
253 | var msg = NewMethodCall(member); | 272 | using (var msg = NewMethodCall(member)) |
254 | |||
255 | foreach (BasicMessageArgument arg in args) | ||
256 | { | 273 | { |
257 | arg.AppendTo(msg); | 274 | foreach (BasicMessageArgument arg in args) |
258 | } | 275 | { |
276 | arg.AppendTo(msg); | ||
277 | } | ||
259 | 278 | ||
260 | return Send(msg, dlgt, timeout); | 279 | return Send(msg, dlgt, timeout); |
280 | } | ||
261 | } | 281 | } |
262 | 282 | ||
263 | eldbus.Pending Call(string member, params BasicMessageArgument[] args) | 283 | eldbus.Pending Call(string member, params BasicMessageArgument[] args) |