1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.ComponentModel;
8 ///<summary>Event argument wrapper for event <see cref="Efl.LoopMessage.MessageEvt"/>.</summary>
9 public class LoopMessageMessageEvt_Args : EventArgs {
10 ///<summary>Actual event payload.</summary>
11 public Efl.LoopMessage arg { get; set; }
13 /// <summary>Base message payload object class. Inherit this and extend for specific message types.</summary>
14 [LoopMessageNativeInherit]
15 public class LoopMessage : Efl.Object, Efl.Eo.IWrapper
17 ///<summary>Pointer to the native class description.</summary>
18 public override System.IntPtr NativeClass {
20 if (((object)this).GetType() == typeof (LoopMessage))
21 return Efl.LoopMessageNativeInherit.GetEflClassStatic();
23 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
26 [System.Runtime.InteropServices.DllImport(efl.Libs.Ecore)] internal static extern System.IntPtr
27 efl_loop_message_class_get();
28 ///<summary>Creates a new instance.</summary>
29 ///<param name="parent">Parent instance.</param>
30 public LoopMessage(Efl.Object parent= null
32 base(efl_loop_message_class_get(), typeof(LoopMessage), parent)
34 FinishInstantiation();
36 ///<summary>Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>
37 protected LoopMessage(System.IntPtr raw) : base(raw)
39 RegisterEventProxies();
41 ///<summary>Internal usage: Constructor to forward the wrapper initialization to the root class that interfaces with native code. Should not be used directly.</summary>
42 protected LoopMessage(IntPtr base_klass, System.Type managed_type, Efl.Object parent) : base(base_klass, managed_type, parent) {}
43 ///<summary>Verifies if the given object is equal to this one.</summary>
44 public override bool Equals(object obj)
46 var other = obj as Efl.Object;
49 return this.NativeHandle == other.NativeHandle;
51 ///<summary>Gets the hash code for this object based on the native pointer it points to.</summary>
52 public override int GetHashCode()
54 return this.NativeHandle.ToInt32();
56 ///<summary>Turns the native pointer into a string representation.</summary>
57 public override String ToString()
59 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
61 private static object MessageEvtKey = new object();
62 /// <summary>The message payload data</summary>
63 public event EventHandler<Efl.LoopMessageMessageEvt_Args> MessageEvt
67 string key = "_EFL_LOOP_MESSAGE_EVENT_MESSAGE";
68 if (AddNativeEventHandler(efl.Libs.Ecore, key, this.evt_MessageEvt_delegate)) {
69 eventHandlers.AddHandler(MessageEvtKey , value);
71 Eina.Log.Error($"Error adding proxy for event {key}");
76 string key = "_EFL_LOOP_MESSAGE_EVENT_MESSAGE";
77 if (RemoveNativeEventHandler(key, this.evt_MessageEvt_delegate)) {
78 eventHandlers.RemoveHandler(MessageEvtKey , value);
80 Eina.Log.Error($"Error removing proxy for event {key}");
84 ///<summary>Method to raise event MessageEvt.</summary>
85 public void On_MessageEvt(Efl.LoopMessageMessageEvt_Args e)
87 EventHandler<Efl.LoopMessageMessageEvt_Args> evt;
89 evt = (EventHandler<Efl.LoopMessageMessageEvt_Args>)eventHandlers[MessageEvtKey];
93 Efl.EventCb evt_MessageEvt_delegate;
94 private void on_MessageEvt_NativeCallback(System.IntPtr data, ref Efl.Event.NativeStruct evt)
96 Efl.LoopMessageMessageEvt_Args args = new Efl.LoopMessageMessageEvt_Args();
97 args.arg = (Efl.Eo.Globals.CreateWrapperFor(evt.Info) as Efl.LoopMessage);
100 } catch (Exception e) {
101 Eina.Log.Error(e.ToString());
102 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
106 ///<summary>Register the Eo event wrappers making the bridge to C# events. Internal usage only.</summary>
107 protected override void RegisterEventProxies()
109 base.RegisterEventProxies();
110 evt_MessageEvt_delegate = new Efl.EventCb(on_MessageEvt_NativeCallback);
112 private static IntPtr GetEflClassStatic()
114 return Efl.LoopMessage.efl_loop_message_class_get();
117 public class LoopMessageNativeInherit : Efl.ObjectNativeInherit{
118 public new static Efl.Eo.NativeModule _Module = new Efl.Eo.NativeModule(efl.Libs.Ecore);
119 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
121 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
122 var methods = Efl.Eo.Globals.GetUserMethods(type);
123 descs.AddRange(base.GetEoOps(type));
126 public override IntPtr GetEflClass()
128 return Efl.LoopMessage.efl_loop_message_class_get();
130 public static new IntPtr GetEflClassStatic()
132 return Efl.LoopMessage.efl_loop_message_class_get();