/// <summary> /// This function initializices everything in EFL and runs your application. /// This call will result in a call to OnInitialize(), which you application should override. /// </summary> public void Launch(Efl.Csharp.Components components = Components.Ui) { Init(components); Efl.App app = Efl.App.AppMain; Eina.Array <String> command_line = new Eina.Array <String>(); command_line.Append(Environment.GetCommandLineArgs()); #if EFL_BETA app.SetCommandArray(command_line); #endif app.ArgumentsEvt += (object sender, LoopArgumentsEvt_Args evt) => { if (evt.arg.Initialization) { OnInitialize(evt.arg.Argv); } OnArguments(evt.arg); }; app.PauseEvt += (object sender, EventArgs e) => { OnPause(); }; app.ResumeEvt += (object sender, EventArgs e) => { OnResume(); }; app.TerminateEvt += (object sender, EventArgs e) => { OnTerminate(); }; app.Begin(); Shutdown(); }
public static void event_with_array_payload() { var obj = new Dummy.TestObject(); List <string> received = null; Eina.Array <string> sent = new Eina.Array <string>(); sent.Append("Abc"); sent.Append("Def"); sent.Append("Ghi"); obj.EvtWithArrayEvent += (object sender, Dummy.TestObjectEvtWithArrayEventArgs e) => { received = e.Arg as List <string>; }; obj.EmitEventWithArray(sent); Test.AssertEquals(sent.Count, received.Count); var pairs = sent.Zip(received, (string sentItem, string receivedItem) => new { Sent = sentItem, Received = receivedItem }); foreach (var pair in pairs) { Test.AssertEquals(pair.Sent, pair.Received); } sent.Dispose(); obj.Dispose(); }
private static bool command_array_set(System.IntPtr obj, System.IntPtr pd, System.IntPtr array) { Eina.Log.Debug("function efl_core_command_line_command_array_set was called"); var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj); if (ws != null) { var _in_array = new Eina.Array <Eina.Stringshare>(array, true, true); bool _ret_var = default(bool); try { _ret_var = ((ICommandLine)ws.Target).SetCommandArray(_in_array); } catch (Exception e) { Eina.Log.Warning($"Callback error: {e.ToString()}"); Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION); } return(_ret_var); } else { return(efl_core_command_line_command_array_set_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), array)); } }
public static void TestIdxOutBounds() { var array = new Eina.Array <int>(); array.Add(4); Test.AssertRaises <ArgumentOutOfRangeException>(() => array.At(1)); Test.AssertRaises <ArgumentOutOfRangeException>(() => array.At(-1)); Test.AssertNotRaises <ArgumentOutOfRangeException> (() => array.At(array.IndexOf(4))); }
public static void TestAdd() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); array.Add(1); Test.AssertEquals(array.Count, 1); array.Add(2); Test.AssertEquals(array.Count, 2); }
/// <summary>Use an array to fill this object /// Every element of a string is a argument.</summary> /// <param name="array">An array where every array field is an argument</param> /// <returns>On success <c>true</c>, <c>false</c> otherwise</returns> virtual public bool SetCommandArray(Eina.Array <System.String> array) { var _in_array = array.Handle; array.Own = false; array.OwnContent = false; var _ret_var = Efl.Core.ICommandLineNativeInherit.efl_core_command_line_command_array_set_ptr.Value.Delegate((inherited ? Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass) : this.NativeHandle), _in_array); Eina.Error.RaiseIfUnhandledException(); return(_ret_var); }
/// <summary>Use an array to fill this object /// Every element of a string is a argument.</summary> /// <param name="array">An array where every array field is an argument</param> /// <returns>On success <c>true</c>, <c>false</c> otherwise</returns> virtual public bool SetCommandArray(Eina.Array <Eina.Stringshare> array) { var _in_array = array.Handle; array.Own = false; array.OwnContent = false; var _ret_var = Efl.Core.ICommandLineConcrete.NativeMethods.efl_core_command_line_command_array_set_ptr.Value.Delegate((IsGeneratedBindingClass ? this.NativeHandle : Efl.Eo.Globals.efl_super(this.NativeHandle, this.NativeClass)), _in_array); Eina.Error.RaiseIfUnhandledException(); return(_ret_var); }
/// <summary>Use an array to fill this object /// Every element of a string is a argument.</summary> /// <param name="array">An array where every array field is an argument</param> /// <returns>On success <c>true</c>, <c>false</c> otherwise</returns> public bool SetCommandArray(Eina.Array <Eina.Stringshare> array) { var _in_array = array.Handle; array.Own = false; array.OwnContent = false; var _ret_var = Efl.Core.ICommandLineConcrete.NativeMethods.efl_core_command_line_command_array_set_ptr.Value.Delegate(this.NativeHandle, _in_array); Eina.Error.RaiseIfUnhandledException(); return(_ret_var); }
public static void TestContains() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); Test.Assert(!array.Contains(0)); array.Add(0); Test.Assert(array.Contains(0)); Test.Assert(array.Remove(0)); Test.Assert(!array.Contains(0)); array.Add(1); array.Add(0); Test.Assert(array.Contains(0)); }
public static void TestIsReadOnly() { var array = new Eina.Array <int>(); int[] tmp = { 1, 3, 2, 6, 5 }; array.Append(tmp); Test.AssertEquals(array.Count, 5); array.SetOwnership(false); Test.AssertRaises <NotSupportedException>(() => array.Add(4)); Test.AssertRaises <NotSupportedException>(() => array.Push(6)); Test.AssertRaises <NotSupportedException>(() => array.Append(tmp)); Test.AssertEquals(array.Count, 5); Test.AssertRaises <NotSupportedException>(() => array.DataSet(2, 4)); Test.Assert(array.ToArray().SequenceEqual(tmp)); }
public static void TestObjectContainerFromToObject() { var initialBag = new Eina.Array <Efl.Object>(); var tmp1 = new Dummy.TestObject(); var tmp2 = new Dummy.TestObject(); var tmp3 = new Dummy.TestObject(); initialBag.Push(tmp1); initialBag.Push(tmp2); initialBag.Push(tmp3); var source = new ComplexHolder { BagOfObjects = initialBag }; var prop = source.GetType().GetProperty("BagOfObjects"); var v = new Eina.Value(prop.GetValue(source)); Test.AssertEquals(prop.GetValue(source), initialBag); Test.AssertEquals(v.GetValueType(), Eina.ValueType.Array); Test.AssertEquals(v.GetValueSubType(), Eina.ValueType.Object); Test.AssertEquals(v[0], initialBag[0]); Test.AssertEquals(v[1], initialBag[1]); Test.AssertEquals(v[2], initialBag[2]); var first = new Dummy.TestObject(); var second = new Dummy.TestObject(); var third = new Dummy.TestObject(); v[0] = first; v[1] = second; v[2] = third; prop.SetValue(source, v.Unwrap()); IEnumerable <Efl.Object> newVal = prop.GetValue(source) as IEnumerable <Efl.Object>; var toCheck = newVal.ToList(); Test.AssertEquals(toCheck[0], first); Test.AssertEquals(toCheck[1], second); Test.AssertEquals(toCheck[2], third); tmp3.Dispose(); tmp2.Dispose(); tmp1.Dispose(); v.Dispose(); }
/// <summary> /// This function initializices everything in EFL and runs your application. /// This call will result in a call to OnInitialize(), which you application should override. /// <para>Since EFL 1.23.</para> /// </summary> /// <param name="components">The <see cref="Efl.Csharp.Components" /> to run the application.</param> public void Launch(Efl.Csharp.Components components = Components.All) { Init(components); Efl.App app = Efl.App.AppMain; var command_line = new Eina.Array <Eina.Stringshare>(); //command_line.Add(List.ConvertAll(Environment.GetCommandLineArgs(), s => (Eina.Stringshare)s)); //command_line.AddRange(Environment.GetCommandLineArgs()); #if EFL_BETA app.SetCommandArray(command_line); #endif app.ArgumentsEvent += (object sender, LoopArgumentsEventArgs evt) => { if (evt.arg.Initialization) { var evtArgv = evt.arg.Argv; int n = evtArgv.Count; var argv = new string[n]; for (int i = 0; i < n; ++i) { argv[i] = evtArgv[i]; } OnInitialize(argv); } OnArguments(evt.arg); }; app.PauseEvent += (object sender, EventArgs e) => { OnPause(); }; app.ResumeEvent += (object sender, EventArgs e) => { OnResume(); }; app.TerminateEvent += (object sender, EventArgs e) => { OnTerminate(); }; app.Begin(); command_line.Dispose(); Shutdown(); }
public static void TestRemoveAt() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); array.Add(1); Test.AssertEquals(array.Count, 1); Test.AssertEquals(array[0], 1); array.RemoveAt(0); Test.AssertEquals(array.Count, 0); array.Add(1); array.Add(0); array.Add(1); Test.AssertEquals(array.Count, 3); Test.AssertEquals(array[2], 1); array.RemoveAt(2); Test.AssertEquals(array.Count, 2); Test.AssertEquals(array[0], 1); }
public static void TestIndexOf() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); array.Add(1); Test.AssertEquals(array.Count, 1); Test.AssertEquals(0, array.IndexOf(1)); array.Insert(0, 0); Test.AssertEquals(array.Count, 2); Test.AssertEquals(0, array.IndexOf(0)); Test.AssertEquals(1, array.IndexOf(1)); array.Insert(0, 1); Test.AssertEquals(array.Count, 3); Test.AssertEquals(0, array.IndexOf(1)); Test.AssertEquals(1, array.IndexOf(0)); array.Insert(0, 1); Test.AssertEquals(array.Count, 4); Test.AssertEquals(0, array.IndexOf(1)); Test.AssertEquals(2, array.IndexOf(0)); }
public static void TestCopyTo() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); int[] random = { 4, 40, 10, 42, 99 }; array.Add(43); array.Insert(0, 1); array.Insert(1, 50); Test.AssertEquals(array.Count, 3); Array.ForEach(random, (n) => array.Add(n)); Test.AssertEquals(array.Count, 8); int[] expected = { 1, 50, 43, 4, 40, 10, 42, 99 }; var result = new int[expected.Length]; array.CopyTo(result, 0); for (int i = 0; i < expected.Length; ++i) { Test.AssertEquals(expected[i], result[i]); } }
public static void TestInsert() { IList <int> array = new Eina.Array <int>(); array.Add(99); Test.AssertEquals(array.Count, 1); array.Insert(0, 6); Test.AssertEquals(array.Count, 2); Test.AssertEquals(array[0], 6); array.Insert(1, 5); Test.AssertEquals(array.Count, 3); Test.AssertEquals(array[1], 5); array.Insert(1, 10); Test.AssertEquals(array.Count, 4); Test.AssertEquals(array[1], 10); array.RemoveAt(1); Test.AssertEquals(array.Count, 3); Test.AssertEquals(array[1], 5); array.Insert(1, 42); Test.AssertEquals(array.Count, 4); Test.AssertEquals(array[1], 42); }
public static void TestContainerFromToObject() { var initialBag = new Eina.Array <int>(); initialBag.Push(2); initialBag.Push(4); initialBag.Push(6); var source = new ComplexHolder { Bag = initialBag }; var prop = source.GetType().GetProperty("Bag"); var v = new Eina.Value(prop.GetValue(source)); Test.AssertEquals(prop.GetValue(source), initialBag); Test.AssertEquals(v.GetValueType(), Eina.ValueType.Array); Test.AssertEquals(v.GetValueSubType(), Eina.ValueType.Int32); Test.AssertEquals(v[0], initialBag[0]); Test.AssertEquals(v[1], initialBag[1]); Test.AssertEquals(v[2], initialBag[2]); v[0] = 100; v[1] = 200; v[2] = 300; prop.SetValue(source, v.Unwrap()); IEnumerable <int> newVal = prop.GetValue(source) as IEnumerable <int>; var toCheck = newVal.ToList(); Test.AssertEquals(toCheck[0], 100); Test.AssertEquals(toCheck[1], 200); Test.AssertEquals(toCheck[2], 300); v.Dispose(); }
public static void TestClear() { IList <int> array = new Eina.Array <int>(); Test.AssertEquals(array.Count, 0); array.Clear(); Test.AssertEquals(array.Count, 0); array.Add(0); Test.AssertEquals(array.Count, 1); array.Clear(); Test.AssertEquals(array.Count, 0); array.Add(0); array.Add(0); Test.AssertEquals(array.Count, 2); array.Clear(); Test.AssertEquals(array.Count, 0); array.Add(0); array.Add(0); Test.AssertEquals(array.Count, 2); Test.Assert(array.Remove(0)); Test.AssertEquals(array.Count, 1); array.Clear(); Test.AssertEquals(array.Count, 0); }
public static void TestRemove() { IList <int> array = new Eina.Array <int>(); Test.Assert(!array.Remove(0)); Test.AssertEquals(array.Count, 0); array.Add(1); Test.AssertEquals(array.Count, 1); Test.Assert(array.Remove(1)); Test.AssertEquals(array.Count, 0); array.Add(1); array.Add(1); Test.AssertEquals(array.Count, 2); Test.Assert(array.Remove(1)); Test.AssertEquals(array.Count, 1); array.Add(0); array.Add(1); Test.AssertEquals(array[1], 0); Test.AssertEquals(array.Count, 3); Test.Assert(!array.Remove(2)); Test.Assert(array.Remove(1)); Test.AssertEquals(array[1], 1); Test.AssertEquals(array.Count, 2); }
/// <summary> /// Called when the application is started. Arguments from the command line are passed here. /// </summary> protected abstract void OnInitialize(Eina.Array <System.String> args);
///<summary>Constructor for PropertyEvent.</summary> public PropertyEvent( Eina.Array <System.String> Changed_properties = default(Eina.Array <System.String>)) { this.Changed_properties = Changed_properties; }
/// <summary>Constructor for PropertyEvent.</summary> /// <param name="Changed_properties">List of changed properties</param>; public PropertyEvent( Eina.Array <Eina.Stringshare> Changed_properties = default(Eina.Array <Eina.Stringshare>)) { this.Changed_properties = Changed_properties; }