示例#1
0
        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();
        }
示例#2
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));
        }
示例#3
0
            /// <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();
            }
示例#4
0
        /// <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.Append(Array.ConvertAll(Environment.GetCommandLineArgs(), s => (Eina.Stringshare)s));
#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.Length;
                    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();
        }