summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-11-11 11:33:03 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-12 10:17:25 -0300
commit77c1777ca2a9594e04b9b2bac1fc241fdff68445 (patch)
treed55b1bda957ebe599a67d632ac53770cad019862 /src/bindings/mono/eo_mono
parent73494aa71cb5d69092999036eee60b8b4f94ecc5 (diff)
mono: reduce duplicated event code
Summary: Introduction GetInternalEventCallback function to reduce duplicated event code. Test Plan: ninja test Reviewers: lauromoura Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10638
Diffstat (limited to 'src/bindings/mono/eo_mono')
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 4209fa7..0ab80e5 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -325,6 +325,44 @@ public abstract class EoWrapper : IWrapper, IDisposable
325 } 325 }
326 } 326 }
327 } 327 }
328 internal Efl.EventCb GetInternalEventCallback<T>(EventHandler<T> handler, Func<IntPtr, T> createArgsInstance) where T:EventArgs
329 {
330 return (IntPtr data, ref Efl.Event.NativeStruct evt) =>
331 {
332 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
333 if (obj != null)
334 {
335 try
336 {
337 handler?.Invoke(obj, createArgsInstance(evt.Info));
338 }
339 catch (Exception e)
340 {
341 Eina.Log.Error(e.ToString());
342 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
343 }
344 }
345 };
346 }
347 internal Efl.EventCb GetInternalEventCallback(EventHandler handler)
348 {
349 return (IntPtr data, ref Efl.Event.NativeStruct evt) =>
350 {
351 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
352 if (obj != null)
353 {
354 try
355 {
356 handler?.Invoke(obj, EventArgs.Empty);
357 }
358 catch (Exception e)
359 {
360 Eina.Log.Error(e.ToString());
361 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
362 }
363 }
364 };
365 }
328 366
329 private static void OwnershipUniqueCallback(IntPtr data, ref Efl.Event.NativeStruct evt) 367 private static void OwnershipUniqueCallback(IntPtr data, ref Efl.Event.NativeStruct evt)
330 { 368 {