コード例 #1
0
        public object Execute(object sender, object parameter)
        {
            var leftType   = LeftValue?.GetType();
            var rightValue = (RightValue == null) ? null : Convert.ChangeType(RightValue, leftType);

            switch (Operator)
            {
            case Operators.EqualToRight:
            default:
                if (Compare(LeftValue, rightValue) == 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.NotEqualToRight:
                if (Compare(LeftValue, rightValue) != 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.LessThanRight:
                if (Compare(LeftValue, rightValue) > 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.LessThanOrEqualToRight:
                if (Compare(LeftValue, rightValue) >= 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.GreaterThanRight:
                if (Compare(LeftValue, rightValue) < 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.GreaterThanOrEqualToRight:
                if (Compare(LeftValue, rightValue) <= 0)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsNull:
                if (LeftValue == null)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsNotNull:
                if (LeftValue != null)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsTrue:
                if ((bool?)LeftValue ?? false)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsFalse:
                if (!(bool?)LeftValue ?? false)
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsNullOrEmpty:
                if (string.IsNullOrEmpty(LeftValue as string))
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;

            case Operators.IsNotNullOrEmpty:
                if (!string.IsNullOrEmpty(LeftValue as string))
                {
                    Interaction.ExecuteActions(sender, Actions, parameter);
                }

                break;
            }
            return(null);
        }
コード例 #2
0
        public object Execute(object sender, object parameter)
        {
            var leftType   = LeftValue?.GetType();
            var rightValue = (RightValue == null) ? null : Convert.ChangeType(RightValue, leftType);

            switch (Operator)
            {
            case Operators.Equal:
            default:
                if (Compare(LeftValue, rightValue) == 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.NotEqual:
                if (Compare(LeftValue, rightValue) != 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.LessThan:
                if (Compare(LeftValue, rightValue) > 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.LessThanOrEqual:
                if (Compare(LeftValue, rightValue) >= 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.GreaterThan:
                if (Compare(LeftValue, rightValue) < 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.GreaterThanOrEqual:
                if (Compare(LeftValue, rightValue) <= 0)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.IsNull:
                if (LeftValue == null)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;

            case Operators.IsNotNull:
                if (LeftValue != null)
                {
                    Interaction.ExecuteActions(this, this.Actions, null);
                }
                break;
            }
            return(null);
        }