using System;
using System.Collections.Generic;
namespace Rokid.UXR.Interaction {
///
/// MAction can be used in place of Action. This allows
/// for interfaces with Actions of generic covariant types
/// to be subscribed to by multiple types of delegates.
///
public interface MAction
{
event Action Action;
}
///
/// Classes that implement an interface that has MActions
/// can use MultiAction as their MAction implementation to
/// allow for multiple types of delegates to subscribe to the
/// generic type.
///
public class MultiAction : MAction
{
protected HashSet> actions = new HashSet>();
public event Action Action
{
add
{
actions.Add(value);
}
remove
{
actions.Remove(value);
}
}
public void Invoke(T t)
{
foreach (Action action in actions)
{
action(t);
}
}
}
}