/// <summary> /// Invokes the action. /// </summary> /// <param name="eventArgs">The parameter to the action. If the action does not require a parameter, the parameter may be set to a null reference.</param> public void Invoke(object eventArgs) { Log.Info("Invoking {0}.", this); if (context == null) { UpdateContext(); } if (context.Target == null || context.View == null) { PrepareContext(context); if (context.Target == null) { var ex = new Exception(string.Format("No target found for method {0}.", context.Message.MethodName)); Log.Error(ex); if (!ThrowsExceptions) { return; } throw ex; } if (!UpdateAvailabilityCore()) { return; } } if (context.Method == null) { var ex = new Exception(string.Format("Method {0} not found on target of type {1}.", context.Message.MethodName, context.Target.GetType())); Log.Error(ex); if (!ThrowsExceptions) { return; } throw ex; } context.EventArgs = eventArgs; if (EnforceGuardsDuringInvocation && context.CanExecute != null && !context.CanExecute()) { return; } InvokeAction(context); context.EventArgs = null; }
private static void SetContentPropertyCore(object targetLocation, object view) { try { if (view is IHaveDataContext) { Log.Info("Setting DC of {0} to {1}.", view, targetLocation); ((IHaveDataContext)view).DataContext = targetLocation; } } catch (Exception e) { Log.Error(e); } }