[This is preliminary documentation and is subject to change.]

Gets the value determining the UIController's handlers

Namespace:  Firefly.Box
Assembly:  Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)

Syntax

C#
public HandlerCollection Handlers { get; }
Visual Basic (Declaration)
Public ReadOnly Property Handlers As HandlerCollection
Visual C++
public:
property HandlerCollection^ Handlers {
	HandlerCollection^ get ();
}

Examples

usage of handlers
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
CopyC#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class TaskInvoke
    {
        [Test]
        public void UsageOfCustomCommand()
        {
            var bp = new BusinessProcess();
            var command = new CustomCommand();
            bool happened = false;
            bp.Handlers.Add(command).Invokes += e => happened = true;
            bp.ForFirstRow(() =>
            {
                happened.ShouldBe(false);
                bp.Invoke(command);
                happened.ShouldBe(true);
            });
        }
        [Test]
        public void UsageOfCustomCommandAndIdleTiming()
        {
            var bp = new BusinessProcess();
            var command = new CustomCommand();
            bool happened = false;
            bp.Handlers.Add(command).Invokes += e => happened = true;
            bp.ForFirstRow(() =>
            {
                happened.ShouldBe(false);
                bp.Raise(command);
                happened.ShouldBe(false);//The handler doesn't happen immediately,
                //but will be handled the next time the application is idle, 
                //usually in the next active UIController
            });
        }

        [Test]
        public void InvokingACustomCommandByKey()
        {
            var bp = new BusinessProcess();
            var command = new CustomCommand() {Name = "command name", Key = "Key", AllowInvokeByKey = CustomCommandAllowInvokeByKey.Always };
            bool happened = false;
            bp.Handlers.Add(command).Invokes += e => happened = true;
            bp.ForFirstRow(() =>
            {
                happened.ShouldBe(false);
                bp.Invoke("Key");
                happened.ShouldBe(true);
            });
        }


        [Test]
        public void AnInvokedCommandBublesBetweenDeferentTasks()
        {
            var bp = new BusinessProcess();
            var command = new CustomCommand();
            bool happened = false;
            bp.Handlers.Add(command).Invokes += e => happened = true;
            bp.ForFirstRow(() =>
            {
                var childBp = new BusinessProcess();
                childBp.ForFirstRow(() =>
                {
                    childBp.Invoke(command);
                    happened.ShouldBe(true);
                });
            });
        }
    }
}

See Also