public ValidationResult IsFormulaValid( string formula, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator) { if (this.get_Log().get_IsDebugEnabled()) { this.get_Log().DebugFormat("Validating formula: {0} ...", (object)formula); } ValidationResult validationResult; try { validationResult = this._preProcessor.PreValidateFormula(formula, level, thresholdOperator); if (validationResult.get_IsValid()) { formula = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator); this._variables = CoreThresholdProcessor.CreateVariables(CoreThresholdProcessor.CreateDefaultBaselineValues()); this.TryParse(formula, true); validationResult = ValidationResult.CreateValid(); } } catch (InvalidInputException ex) { validationResult = !ex.get_HasError() ? new ValidationResult(false, ((Exception)ex).Message) : new ValidationResult(false, (IEnumerable <string>)((IEnumerable <ExprEvalErrorDescription>)ex.get_Errors()).Select <ExprEvalErrorDescription, string>((Func <ExprEvalErrorDescription, string>)(er => CoreThresholdProcessor.GetErrorMessage(er))).ToArray <string>()); } catch (Exception ex) { this.get_Log().Error((object)string.Format("Unexpected error when validating formula: {0} ", (object)formula), ex); validationResult = new ValidationResult(false, ex.Message); } return(validationResult); }
// Token: 0x060004CF RID: 1231 RVA: 0x0001E3F8 File Offset: 0x0001C5F8 public double ComputeThreshold(string formula, BaselineValues baselineValues, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator) { if (base.Log.IsVerboseEnabled) { base.Log.VerboseFormat("Computing formula: {0}, values: [{1}]", new object[] { formula, baselineValues }); } if (string.IsNullOrEmpty(formula)) { return(0.0); } double result; try { formula = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator); this._variables = CoreThresholdProcessor.CreateVariables(baselineValues); result = base.EvaluateDynamic(formula, this._variables, null); } catch (InvalidInputException ex) { string text; if (ex.HasError) { text = string.Join(" ", ex.Errors.Select(new Func <ExprEvalErrorDescription, string>(CoreThresholdProcessor.GetErrorMessage)).ToArray <string>()); } else { text = ex.Message; } if (base.Log.IsInfoEnabled) { base.Log.Info(string.Format("Parsing error: {0} when evaluating formula: {1}, values: {2}", text, formula, baselineValues), ex); } throw new Exception(text, ex); } catch (Exception ex2) { base.Log.Error(string.Format("Unexpected error when evaluating formula: {0}, values: {1}", formula, baselineValues), ex2); throw; } return(result); }
public double ComputeThreshold( string formula, BaselineValues baselineValues, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator) { if (this.get_Log().get_IsVerboseEnabled()) { this.get_Log().VerboseFormat("Computing formula: {0}, values: [{1}]", new object[2] { (object)formula, (object)baselineValues }); } if (string.IsNullOrEmpty(formula)) { return(0.0); } try { formula = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator); this._variables = CoreThresholdProcessor.CreateVariables(baselineValues); return(this.EvaluateDynamic(formula, (IDictionary <string, Variable>) this._variables, (object)null)); } catch (InvalidInputException ex) { string message = !ex.get_HasError() ? ((Exception)ex).Message : string.Join(" ", ((IEnumerable <ExprEvalErrorDescription>)ex.get_Errors()).Select <ExprEvalErrorDescription, string>(new Func <ExprEvalErrorDescription, string>(CoreThresholdProcessor.GetErrorMessage)).ToArray <string>()); if (this.get_Log().get_IsInfoEnabled()) { this.get_Log().Info((object)string.Format("Parsing error: {0} when evaluating formula: {1}, values: {2}", (object)message, (object)formula, (object)baselineValues), (Exception)ex); } throw new Exception(message, (Exception)ex); } catch (Exception ex) { this.get_Log().Error((object)string.Format("Unexpected error when evaluating formula: {0}, values: {1}", (object)formula, (object)baselineValues), ex); throw; } }
// Token: 0x060004CE RID: 1230 RVA: 0x0001E2F0 File Offset: 0x0001C4F0 public ValidationResult IsFormulaValid(string formula, ThresholdLevel level, ThresholdOperatorEnum thresholdOperator) { if (base.Log.IsDebugEnabled) { base.Log.DebugFormat("Validating formula: {0} ...", formula); } ValidationResult validationResult; try { validationResult = this._preProcessor.PreValidateFormula(formula, level, thresholdOperator); if (validationResult.IsValid) { formula = this._preProcessor.PreProcessFormula(formula, level, thresholdOperator); this._variables = CoreThresholdProcessor.CreateVariables(CoreThresholdProcessor.CreateDefaultBaselineValues()); base.TryParse(formula, true); validationResult = ValidationResult.CreateValid(); } } catch (InvalidInputException ex) { if (ex.HasError) { validationResult = new ValidationResult(false, (from er in ex.Errors select CoreThresholdProcessor.GetErrorMessage(er)).ToArray <string>()); } else { validationResult = new ValidationResult(false, ex.Message); } } catch (Exception ex2) { base.Log.Error(string.Format("Unexpected error when validating formula: {0} ", formula), ex2); validationResult = new ValidationResult(false, ex2.Message); } return(validationResult); }