public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     var valid = true;
     var elementsToValidate = GetFieldSetChildren(handlingNode.UIElement as FrameworkElement);
     foreach(var element in elementsToValidate)
     {
         if(!element.IsVisible || !element.IsEnabled)
             continue;
         var propertyToValidate = FieldSet.GetPropertyToValidate(element);
         if(string.IsNullOrEmpty(propertyToValidate))
             continue;
         var fieldInfo = GetField(element.GetType(), string.Format("{0}Property", propertyToValidate));
         if(fieldInfo == null)
             continue;
         var property = fieldInfo.GetValue(element) as DependencyProperty;
         if(property == null)
             continue;
         var expression = BindingOperations.GetBindingExpression(element, property);
         if(expression == null)
             continue;
         expression.UpdateSource();
         var errors = Validation.GetErrors(element);
         if(errors != null && errors.Any())
             valid = false;
     }
     return valid;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the filter.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            var result = _method.Invoke(handlingNode.MessageHandler.Unwrap(), parameters);

            if (_method.Info.ReturnType == typeof(bool)) return (bool)result;
            return true;
        }
Ejemplo n.º 3
0
        public bool BeforeExecute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            var methodName = message.As<ActionMessage>().MethodName;

            var questionPresenter = ServiceLocator.Current.GetInstance<IQuestionPresenter>();
            var param = parameters.Add(questionPresenter).ToArray();
            var target = handlingNode.MessageHandler.Unwrap();
            var targetParams = target.GetType().GetMethod(methodName).GetParameters();

            //Prepare
            if (_prepareMethod.IsNotNull())
            {
                var prepareParams = InvocationExtension.GetArguments(param, targetParams, _prepareMethod.Info.GetParameters());

                var prepareResult = _prepareMethod.Invoke(target, prepareParams);
                if (prepareResult != null)
                {
                    if (prepareResult is bool)
                        return (bool) prepareResult;
                }
            }

            //Show
            ServiceLocator.Current.GetInstance<IWindowManager>().ShowDialog(questionPresenter);

            //Callback
            if (_callbackMethod.IsNull())
                return questionPresenter.Answer == Answer.Yes;

            var callbackParams = InvocationExtension.GetArguments(param, targetParams, _callbackMethod.Info.GetParameters());
            var result = _callbackMethod.Invoke(target, callbackParams);

            if (_callbackMethod.Info.ReturnType == typeof(bool)) return (bool)result;
            return true;
        }
 public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     bool result=PermissionHelper.IsViewEnabled(_screenType);
     if(!result)
         message.AvailabilityEffect = AvailabilityEffect.Collapse;
     return result;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Executes the filter.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="outcome">The outcome of processing the message</param>
        public virtual void Execute(IRoutedMessage message, IInteractionNode handlingNode, MessageProcessingOutcome outcome)
        {
            if(callback == null || outcome.WasCancelled)
                return;

            outcome.Result = callback.Invoke(handlingNode.MessageHandler.Unwrap(), outcome.Result);
            outcome.ResultType = callback.Info.ReturnType;
        }
Ejemplo n.º 6
0
        public static void Send(this DependencyObject origin, IRoutedMessage message, object context)
        {
            var node = origin.GetValue(DefaultRoutedMessageController.NodeProperty) as IInteractionNode;

            if (node != null)

                node.ProcessMessage(message, context);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Processes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="context">An object that provides additional context for message processing.</param>
        public void Process(IRoutedMessage message, object context)
        {
            var actionMessage = message as ActionMessage;

            if (actionMessage != null)
                _host.GetAction(actionMessage).Execute(actionMessage, _node, context);
            else throw new CaliburnException("The handler cannot process this message.");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles an <see cref="Exception"/>.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="exception">The exception.</param>
        /// <returns>
        /// true if the exception was handled, false otherwise
        /// </returns>
        public bool Handle(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
        {
            var result = _method.Invoke(handlingNode.MessageHandler.Unwrap(), exception);

            if(_method.Info.ReturnType == typeof(bool))
                return (bool)result;
            return true;
        }
Ejemplo n.º 9
0
		/// <summary>
		/// Executes the filter.
		/// </summary>
		/// <param name="message">The message.</param>
		/// <param name="handlingNode">The handling node.</param>
		/// <param name="parameters">The parameters.</param>
		/// <returns></returns>
		public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
		{
			var target = handlingNode.MessageHandler.Unwrap();
			if (target == null)
				return false;

			var result = Method.Invoke(target, parameters);

			if (Method.Info.ReturnType == typeof(bool))
				return (bool)result;
			return true;
		}
Ejemplo n.º 10
0
        bool IPreProcessor.Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {  
            var target = handlingNode.MessageHandler.Unwrap();

            var inputPresenter = ServiceLocator.Current.GetInstance<IDialogBoxPresenter>();
            inputPresenter.Invoker = target;
            inputPresenter.ConfirmDelegate = ConfirmDelegate;
            inputPresenter.PartView = PartView;
            parameters[0] = inputPresenter;

            return true;
        }
Ejemplo n.º 11
0
 public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     message.AvailabilityEffect = Effect;
     
     var functionKeys = ApplicationCache.Get<ICollection<string>>(Global.LoginUserFunctionKeys);
     if (functionKeys == null || functionKeys.Count == 0)
     {
         //Admin
         return true;
     }
     return functionKeys.Contains(FunctionKey);
 }
Ejemplo n.º 12
0
		bool IPreProcessor.Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            //TODO: support of syncronous tasks
            var bgTask = AsynchronousAction.CurrentTask;
            if(bgTask == null)
                throw new InvalidOperationException("ActionInfo attribute can only be used on asynchronous actions");

            var runningAction = new RunningAction(bgTask, IsIndeterminate, IsCancellable)
            {
                Title = Title
            };

            _runningActionPresenter.RegisterTask(runningAction);
            bgTask.Completed += (o, e) => _runningActionPresenter.UnregisterTask(runningAction);

            return true;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Executes the filter.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            var target = handlingNode.MessageHandler.Unwrap();

            if (target == null)
            {
                return(false);
            }

            var result = Method.Invoke(target, parameters);

            if (Method.Info.ReturnType == typeof(bool))
            {
                return((bool)result);
            }
            return(true);
        }
Ejemplo n.º 14
0
        public bool BeforeExecute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            var methodName = message.As <ActionMessage>().MethodName;

            var questionPresenter = ServiceLocator.Current.GetInstance <IQuestionPresenter>();
            var param             = parameters.Add(questionPresenter).ToArray();
            var target            = handlingNode.MessageHandler.Unwrap();
            var targetParams      = target.GetType().GetMethod(methodName).GetParameters();

            //Prepare
            if (_prepareMethod.IsNotNull())
            {
                var prepareParams = InvocationExtension.GetArguments(param, targetParams, _prepareMethod.Info.GetParameters());

                var prepareResult = _prepareMethod.Invoke(target, prepareParams);
                if (prepareResult != null)
                {
                    if (prepareResult is bool)
                    {
                        return((bool)prepareResult);
                    }
                }
            }

            //Show
            ServiceLocator.Current.GetInstance <IWindowManager>().ShowDialog(questionPresenter);

            //Callback
            if (_callbackMethod.IsNull())
            {
                return(questionPresenter.Answer == Answer.Yes);
            }

            var callbackParams = InvocationExtension.GetArguments(param, targetParams, _callbackMethod.Info.GetParameters());
            var result         = _callbackMethod.Invoke(target, callbackParams);

            if (_callbackMethod.Info.ReturnType == typeof(bool))
            {
                return((bool)result);
            }
            return(true);
        }
Ejemplo n.º 15
0
        bool IPreProcessor.Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            //TODO: support of syncronous tasks
            var bgTask = AsynchronousAction.CurrentTask;

            if (bgTask == null)
            {
                throw new InvalidOperationException("ActionInfo attribute can only be used on asynchronous actions");
            }

            var runningAction = new RunningAction(bgTask, IsIndeterminate, IsCancellable)
            {
                Title = Title
            };

            registry.RegisterTask(runningAction);
            bgTask.Completed += (o, e) => registry.UnregisterTask(runningAction);

            return(true);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Handles an <see cref="Exception"/>.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="exception">The exception.</param>
        /// <returns>
        /// true if the exception was handled, false otherwise
        /// </returns>
        public bool Handle(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
        {
            object result;

            if (RunMethodBeforeDialog)
            {
                result = RunMethod(message, handlingNode, exception);
                ShowDialog(exception);
            }
            else
            {
                ShowDialog(exception);
                result = RunMethod(message, handlingNode, exception);
            }

            if (_method.Info.ReturnType == typeof(bool))
            {
                return((bool)result);
            }
            return(true);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Determines the parameters that a method should be invoked with.
        /// </summary>
        /// <param name="message">The message to determine the parameters for.</param>
        /// <param name="requiredParameters">The requirements for method binding.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="context">The context.</param>
        /// <returns>The actual parameters</returns>
        public virtual object[] DetermineParameters(IRoutedMessage message, IList<RequiredParameter> requiredParameters, IInteractionNode handlingNode, object context)
        {
            if (requiredParameters == null || requiredParameters.Count == 0)
                return new object[] {};

            var providedValues = message.Parameters.Select(x => x.Value).ToArray();

            if (requiredParameters.Count == providedValues.Length)
                return CoerceValues(requiredParameters, providedValues, message.Source, context);

            if (providedValues.Length == 0)
                return LocateAndCoerceValues(requiredParameters, message.Source, handlingNode, context);

            throw new CaliburnException(
                string.Format(
                    "Parameter count mismatch.  {0} parameters were provided but {1} are required for {2}.",
                    providedValues.Length,
                    requiredParameters.Count,
                    message
                    )
                );
        }
Ejemplo n.º 18
0
        private IRoutedMessageHandler FindHandlerOrFail(IRoutedMessage message, bool shouldFail)
        {
            IInteractionNode currentNode = this;

            while (currentNode != null && !currentNode.Handles(message))
            {
                currentNode = currentNode.FindParent();
            }

            if (currentNode == null)
            {
                foreach (var handler in message.GetDefaultHandlers(this))
                {
                    if (handler.Handles(message))
                    {
                        RegisterHandler(handler);
                        return(handler);
                    }
                }

                var info = string.Format(
                    "There was no handler found for the message {0}.",
                    message
                    );

                if (shouldFail)
                {
                    var exception = new CaliburnException(info);
                    Log.Error(exception);
                    throw exception;
                }

                Log.Info(info);
            }

            return(currentNode != null ? currentNode.MessageHandler : null);
        }
        public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
        {
            var valid = true;
            var elementsToValidate = FieldSet.GetChildren(handlingNode.UIElement as FrameworkElement, fieldSetName);

            foreach (var element in elementsToValidate)
            {
                if (!element.IsVisible || !element.IsEnabled)
                {
                    continue;
                }

                var propertyToValidate = FieldSet.GetPropertyToValidate(element);
                if (string.IsNullOrEmpty(propertyToValidate))
                {
                    continue;
                }

                var property   = FieldSet.GetDependencyProperty(element.GetType(), propertyToValidate);
                var expression = BindingOperations.GetBindingExpression(element, property);
                if (expression == null)
                {
                    continue;
                }

                expression.UpdateSource();

                var errors = Validation.GetErrors(element);
                if (errors != null && errors.Any())
                {
                    valid = false;
                }
            }

            return(valid);
        }
Ejemplo n.º 20
0
        private IRoutedMessageHandler FindHandlerOrFail(IRoutedMessage message, bool shouldFail)
        {
            IInteractionNode currentNode = this;

            while(currentNode != null && !currentNode.Handles(message))
            {
                currentNode = currentNode.FindParent();
            }

            if(currentNode == null)
            {
                foreach(var handler in message.GetDefaultHandlers(this))
                {
                    if (handler.Handles(message))
                    {
                        RegisterHandler(handler);
                        return handler;
                    }
                }

                var info = string.Format(
                    "There was no handler found for the message {0}.",
                    message
                    );

                if (shouldFail)
                {
                    var exception = new CaliburnException(info);
                    Log.Error(exception);
                    throw exception;
                }
                
                Log.Info(info);
            }

            return currentNode != null ? currentNode.MessageHandler : null;
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Processes the message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="context">An object that provides additional context for message processing.</param>
 public void ProcessMessage(IRoutedMessage message, object context)
 {
     FindHandlerOrFail(message, true).Process(message, context);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Processes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="context">An object that provides additional context for message processing.</param>
        public void Process(IRoutedMessage message, object context)
        {
            if (message != this)
            {
                var ex = new CaliburnException("The handler cannot process the message.");
                Log.Error(ex);
                throw ex;
            }

            CreateActionMessage();

            action.Execute(actionMessage, Source, context);

            Log.Info("Processed {0} on command {1}.", actionMessage, Command);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Handles an <see cref="Exception"/>.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="exception">The exception.</param>
        /// <returns>
        /// true if the exception was handled, false otherwise
        /// </returns>
        public bool Handle(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
        {
            object result;
            if (RunMethodBeforeDialog)
            {
                result = RunMethod(message, handlingNode, exception);
                ShowDialog(exception);
            }
            else
            {
                ShowDialog(exception);
                result = RunMethod(message, handlingNode, exception);
            }

            if (_method.Info.ReturnType == typeof(bool))
                return (bool)result;
            return true;
        }
Ejemplo n.º 24
0
 private object RunMethod(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
 {
     return _method.Invoke(handlingNode.MessageHandler.Unwrap(), GetParameters(message, handlingNode, exception));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Indicates whether this instance can handle the speicified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public bool Handles(IRoutedMessage message)
 {
     return(message == this);
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Parses the specified message text.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="messageText">The message text.</param>
        /// <returns>The triggers parsed from the text.</returns>
        protected virtual IMessageTrigger ParseMessage(string messageText, DependencyObject target)
        {
            var    triggerPlusMessage = messageText.Split('=');
            string messageDetail      = triggerPlusMessage.Last()
                                        .Replace("[", string.Empty)
                                        .Replace("]", string.Empty)
                                        .Trim();

            IRoutedMessage message = null;

            foreach (var keyValuePair in messageParsers)
            {
                if (messageDetail.StartsWith(keyValuePair.Key, StringComparison.CurrentCultureIgnoreCase))
                {
                    message = keyValuePair.Value
                              .Parse(target, messageDetail.Remove(0, keyValuePair.Key.Length).Trim());
                    break;
                }
            }

            if (message == null)
            {
                message = messageParsers[defaultMessageParserKey]
                          .Parse(target, messageDetail);
                Log.Info("Using default parser {0} for {1} on {2}.", defaultMessageParserKey, messageText, target);
            }

            IMessageTrigger trigger = null;

            if (triggerPlusMessage.Length == 1)
            {
                var defaults = conventionManager.FindElementConventionOrFail(target);
                trigger = defaults.CreateTrigger();
                Log.Info("Using default trigger {0} for {1} on {2}.", trigger, messageText, target);
            }
            else
            {
                var triggerDetail = triggerPlusMessage[0]
                                    .Replace("[", string.Empty)
                                    .Replace("]", string.Empty)
                                    .Trim();

                foreach (var keyValuePair in triggerParsers)
                {
                    if (triggerDetail.StartsWith(keyValuePair.Key, StringComparison.CurrentCultureIgnoreCase))
                    {
                        trigger = keyValuePair.Value
                                  .Parse(target, triggerDetail.Remove(0, keyValuePair.Key.Length).Trim());
                        break;
                    }
                }
            }

            if (trigger == null)
            {
                var exception = new CaliburnException("Could not determine trigger type.");
                Log.Error(exception);
                throw exception;
            }

            trigger.Message = message;

            return(trigger);
        }
Ejemplo n.º 27
0
 private object RunMethod(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
 {
     return(_method.Invoke(handlingNode.MessageHandler.Unwrap(), GetParameters(message, handlingNode, exception)));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Executes the filter.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="handlingNode">The handling node.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns></returns>
 public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     Role clientRole = new Role{ Name = ClientInfo.Instance.Role};
     foreach (Role acceptRole in AcceptRoles)
     {
         if (acceptRole.Equals(clientRole)) return true;
     }
     return false;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 public bool Equals(IRoutedMessage other)
 {
     return ReferenceEquals(this, other);
 }
Ejemplo n.º 30
0
 public bool Equals(IRoutedMessage other)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 31
0
 public object[] DetermineParameters(IRoutedMessage message, IList <RequiredParameter> requiredParameters,
                                     IInteractionNode handlingNode, object context)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Applies the rescue or fails.
        /// </summary>
        /// <param name="message">The action message.</param>
        /// <param name="handlingNode">The handling node.</param>
        /// <param name="ex">The exception.</param>
        protected virtual bool TryApplyRescue(IRoutedMessage message, IInteractionNode handlingNode, Exception ex)
        {
            foreach (var rescue in _filters.Rescues)
            {
                if (rescue.Handle(message, handlingNode, ex))
                {
                    Log.Info("Rescue applied for {0}.", this);
                    return true;
                }
            }

            Log.Warn("Rescue not applied for {0}.", this);
            return false;
        }
Ejemplo n.º 33
0
 //Note:  The code that will execute before the action.
 public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     return Thread.CurrentPrincipal.IsInRole(_role);
 }
Ejemplo n.º 34
0
 public object[] DetermineParameters(IRoutedMessage message, IList<RequiredParameter> requiredParameters,
                                     IInteractionNode handlingNode, object context)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Determines whethyer the target can handle the specified action.
        /// </summary>
        /// <param name="message">The action details.</param>
        /// <returns></returns>
        public bool Handles(IRoutedMessage message)
        {
            var actionMessage = message as ActionMessage;

            return(actionMessage != null && FindActionHandler(actionMessage) != null);
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 public bool Equals(IRoutedMessage other)
 {
     return(ReferenceEquals(this, other));
 }
Ejemplo n.º 37
0
 private object[] GetParameters(IRoutedMessage message, IInteractionNode handlingNode, Exception exception)
 {
     var target = handlingNode.MessageHandler.Unwrap();
     var callParameters = target.GetType().GetMethod(message.As<ActionMessage>().MethodName, BindingFlags.Instance | BindingFlags.Public).GetParameters();
     var rescueParameters = _method.Info.GetParameters();
     return InvocationExtension.GetArguments(PrepareParameters(message.Parameters, exception), callParameters, rescueParameters);
 }
Ejemplo n.º 38
0
 void IPostProcessor.Execute(IRoutedMessage message, IInteractionNode handlingNode, MessageProcessingOutcome outcome)
 {
     ServiceLocator.Current.GetInstance <IWindowManager>().ShowDialog(outcome.Result);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Indicates whether this instance can handle the speicified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public bool Handles(IRoutedMessage message)
 {
     return message == this;
 }
Ejemplo n.º 40
0
 bool Caliburn.PresentationFramework.Filters.IPreProcessor.Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     // 因为 IBeforeProcessor 也继承 IPreProcessor, 为了让 CustomSynchronousAction 避免执行 2 次, 此方法空跑不做任何事情.
     // 交由 IBeforeProcessor 的实例 BeforeExecute 执行
     return(true);
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>
 /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 public bool Equals(IRoutedMessage other)
 {
     if(other is ActionMessage)
         return ReferenceEquals(actionMessage, other);
     return ReferenceEquals(this, other);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Determines whethyer the target can handle the specified action.
        /// </summary>
        /// <param name="message">The action details.</param>
        /// <returns></returns>
        public bool Handles(IRoutedMessage message)
        {
            var actionMessage = message as ActionMessage;

            return(actionMessage != null && _host.GetAction(actionMessage) != null);
        }
Ejemplo n.º 43
0
 //Note:  The code that will execute before the action.
 public bool Execute(IRoutedMessage message, IInteractionNode handlingNode, object[] parameters)
 {
     return CurrentUser.IsInRole(_role);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Determines whethyer the target can handle the specified action.
 /// </summary>
 /// <param name="message">The action details.</param>
 /// <returns></returns>
 public bool Handles(IRoutedMessage message)
 {
     var actionMessage = message as ActionMessage;
     return actionMessage != null && FindActionHandler(actionMessage) != null;
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Processes the message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="context">An object that provides additional context for message processing.</param>
 public void ProcessMessage(IRoutedMessage message, object context)
 {
     FindHandlerOrFail(message, true).Process(message, context);
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Processes the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="context">An object that provides additional context for message processing.</param>
        public void Process(IRoutedMessage message, object context)
        {
            var actionMessage = message as ActionMessage;

            if (actionMessage != null)
            {
                FindActionHandler(actionMessage).Execute(actionMessage, _node, context);
                Log.Info("Processed message {0}.", actionMessage);
            }
            else
            {
                var ex = new CaliburnException("The handler cannot process this message.");
                Log.Error(ex);
                throw ex;
            }
        }
Ejemplo n.º 47
0
 /// <summary>
 /// Determines whether this node can handle the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public bool Handles(IRoutedMessage message)
 {
     return _messageHandler != null && _messageHandler.Handles(message);
 }
Ejemplo n.º 48
0
 /// <summary>
 /// Determines whether this node can handle the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <returns></returns>
 public bool Handles(IRoutedMessage message)
 {
     return(_messageHandler != null && _messageHandler.Handles(message));
 }