void UpdateContext() { context = new ActionExecutionContext { Message = this, Source = AssociatedObject }; PrepareContext(context); UpdateAvailabilityCore(); }
/// <summary> /// Executes a coroutine. /// </summary> /// <param name="coroutine">The coroutine to execute.</param> /// <param name="context">The context to execute the coroutine within.</param> public static void Execute(IEnumerator <IResult> coroutine, ActionExecutionContext context) { Log.Info("Executing coroutine."); var enumerator = CreateParentEnumerator(coroutine); IoC.BuildUp(enumerator); enumerator.Completed += Completed; enumerator.Execute(context); }
/// <summary> /// Determines the parameters that a method should be invoked with. /// </summary> /// <param name="context">The action execution context.</param> /// <param name="requiredParameters">The parameters required to complete the invocation.</param> /// <returns>The actual parameter values.</returns> public static object[] DetermineParameters(ActionExecutionContext context, ParameterInfo[] requiredParameters) { var providedValues = context.Message.Parameters.Select(x => x.Value).ToArray(); var values = new object[requiredParameters.Length]; for (int i = 0; i < requiredParameters.Length; i++) { var value = providedValues[i]; var stringValue = value as string; object potentialValue; if (stringValue != null) { switch (stringValue.ToLower(CultureInfo.InvariantCulture)) { case "$eventargs": potentialValue = context.EventArgs; break; case "$datacontext": potentialValue = context.Source.DataContext; break; case "$source": potentialValue = context.Source; break; default: potentialValue = stringValue; break; } } else { potentialValue = value; } values[i] = CoerceValue(requiredParameters[i].ParameterType, potentialValue); } return(values); }
/// <summary> /// Executes the result using the specified context. /// </summary> /// <param name="context">The context.</param> public void Execute(ActionExecutionContext context) { this.context = context; ChildCompleted(null, new ResultCompletionEventArgs()); }