/// <summary>
        /// Initializes this chain
        /// </summary>
        /// <param name="controller">The controller handled by this chain segment</param>
        internal ExecutionChain(AbstractController controller)
        {
            Children = new List <ExecutionChain>();
            Parents  = new List <ExecutionChain>();

            m_adapters         = new List <StateAdapter>();
            AbstractController = controller;
        }
 /// <summary>
 /// Extracts all state adapter functions from the given controller
 /// </summary>
 /// <param name="controller">The controller to extract state adapters from</param>
 /// <returns>All functions marked with a StateAdapterAttribute which accepts two state objects</returns>
 public static MethodInfo[] ExtractStateAdapters(AbstractController controller)
 {
     return(controller.GetType()
            .GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
            .Where(p => Attribute.IsDefined(p, typeof(StateAdapterAttribute)))
            .Where(p => ValidateAdapterParameters(p))
            .ToArray());
 }
Exemple #3
0
 /// <summary>
 /// Creates a new event executor
 /// </summary>
 /// <param name="controller">The controller containing the event listener</param>
 /// <param name="listener">The method executed using the event</param>
 public EventExecutor(AbstractController controller, MethodInfo listener)
 {
     Listener   = listener;
     Controller = controller;
     ArgTypes   = Listener.GetParameters().Select(p => p.ParameterType).ToArray();
 }
 /// <summary>
 /// Creates a new StateAdapter with a source controller, target controller, and adapter action
 /// </summary>
 /// <param name="source">Controller whose state is the source of adaptation</param>
 /// <param name="target">Controller whose state is the target of adaptation</param>
 /// <param name="adapter">Function used to perform the adaptation</param>
 public StateAdapter(AbstractController source, AbstractController target, MethodInfo adapter)
 {
     _sourceController   = source;
     _targetController   = target;
     _adaptationCallback = adapter;
 }
Exemple #5
0
 /// <summary>
 /// Creates a new EventListener
 /// </summary>
 /// <param name="controller">Controller which handles events this listens for</param>
 /// <param name="method">The method executed by the event</param>
 public EventListener(AbstractController controller, MethodInfo method)
 {
     m_events   = new Queue <EventArgSet>();
     m_executor = new EventExecutor(controller, method);
 }