public override Task <bool> Evaluate(CancellationToken cancellationToken) { return(new Task <bool>(() => { if (LeftValue is string == false) { throw new InvalidOperationException("Matching operator : matching to a regular expression can be applied only on string values. "); } return Regex.IsMatch(LeftValue.ToString(), Pattern); }, cancellationToken, TaskCreationOptions.AttachedToParent)); }
private void Update() { //MiddleCenterTextBlock.Text = (BaseValue + LinkedCharacteristicValue).ToString(); if (UsesLinkedCharacteristic) { MiddleLeftTextBlock.Text = BaseValue.ToString(); MiddleRightTextBlock.Text = (BaseValue + LinkedCharacteristicValue).ToString(); } else { MiddleLeftTextBlock.Text = LeftValue.ToString(); MiddleRightTextBlock.Text = RightValue.ToString(); } }
public override string ToString(string format, IFormatProvider formatProvider) { if (formatProvider == null) { formatProvider = CultureInfo.CurrentCulture; } switch (format.ToUpperInvariant()) { case null: case "": case "G": return(ToString()); case "GRID": return($"{LeftValue.ToString("N2")} {ConditionRelation}"); default: throw new FormatException(String.Format($"The {format} format string is not supported.")); } }
public string ToString(TriggerItem triggerItem) { return($"{LeftValue.ToString(triggerItem)} {OperatorAsString(Operator)} {RightValue.ToString(triggerItem)}"); }
public override string ToString() { return("(" + GetType().Name + " " + LeftValue.ToString() + " " + RightValue.ToString() + ")"); }
private string GetAutoToolTipNumber(Thumb thumb) { var format = (NumberFormatInfo)(NumberFormatInfo.CurrentInfo.Clone()); format.NumberDecimalDigits = this.AutoToolTipPrecision; switch (thumb.Name) { case LeftThumbTemplateName: return(AutoToolTipFormat != null?AutoToolTipFormat(LeftValue, double.NaN) : LeftValue.ToString("N", format)); case RightThumbTemplateName: return(AutoToolTipFormat != null?AutoToolTipFormat(RightValue, double.NaN) : RightValue.ToString("N", format)); case CenterThumbTemplateName: return(AutoToolTipFormat != null?AutoToolTipFormat(LeftValue, RightValue) : (LeftValue.ToString("N", format) + "--" + RightValue.ToString("N", format))); } return("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.EqualTo: default: if (Compare(LeftValue, rightValue) == 0) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.NotEqualTo: if (Compare(LeftValue, rightValue) != 0) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.LessThan: if (Compare(LeftValue, rightValue) < 0) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.LessThanOrEqualTo: if (Compare(LeftValue, rightValue) <= 0) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.GreaterThan: if (Compare(LeftValue, rightValue) > 0) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.GreaterThanOrEqualTo: 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.TryParse(LeftValue?.ToString(), out var rTrue) && rTrue) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.IsFalse: if (bool.TryParse(LeftValue?.ToString(), out var rFalse) && !rFalse) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.IsNullOrEmpty: if (string.IsNullOrEmpty(LeftValue?.ToString())) { Interaction.ExecuteActions(sender, Actions, parameter); } break; case Operators.IsNotNullOrEmpty: if (!string.IsNullOrEmpty(LeftValue?.ToString())) { Interaction.ExecuteActions(sender, Actions, parameter); } break; } return(null); }