public ScientificCalculator( IInputBuffer buffer, IOperatorLookup lookup, IUnitConverter unitConverter, IOperatorConverter operatorConverter, IExpressionBuilder builder, IExpressionParser parser, IEvaluate evaluator, IMemoryStorage memory ) : base( buffer, lookup, unitConverter, operatorConverter, builder, parser, evaluator, memory ) { }
public bool Matches(AutomationElement element, int index) { if (_op == XPathOperator.Union) { throw new System.NotImplementedException(); } IEvaluate canGetValue = _left as IEvaluate; var left = canGetValue.Evaluate(element); switch (_op) { case XPathOperator.Eq: return(_right.Equals(left)); case XPathOperator.Ge: case XPathOperator.Gt: case XPathOperator.Le: case XPathOperator.Lt: case XPathOperator.Ne: break; default: throw new System.Exception("Not a relational operator " + _op); } throw new System.NotImplementedException(); }
public bool SetRoot(IEvaluate <T> root) { AssertIsNotFrozen(); if (Root == root) { return(false); } Root = root; return(true); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (string.IsNullOrEmpty(value)) { failures.Add(new ValidationFailure(nameof(Required), $"Node [{xpath.Expression}] doesn't exist or is empty.")); } return(new ValidationResult(failures)); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (!string.IsNullOrEmpty(value) && Condition(evaluate) && !Predicate(value)) { failures.Add(new ValidationFailure(nameof(ValidateIf), $"Node [{xpath.Expression}] doesn't satify given predicate. Value: [{value}]")); } return(new ValidationResult(failures)); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (!string.IsNullOrEmpty(value) && !(value.Length >= Min && value.Length <= Max)) { failures.Add(new ValidationFailure(nameof(Length), $"Node [{xpath.Expression}] length is outside of given range. Min: [{Min}], Max: [{Max}]. Value: [{value}].")); } return(new ValidationResult(failures)); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (!string.IsNullOrEmpty(value) && value != ExpectedValue) { failures.Add(new ValidationFailure(nameof(Value), $"Node [{xpath.Expression}] is different from [{ExpectedValue}]. Value: [{value}]")); } return(new ValidationResult(failures)); }
public double Calculate(string operation) { if (!String.IsNullOrEmpty(operation)) { IEvaluate evaluator = mapOfOperations[operation]; return(evaluator.evaluate(this.number1, this.number2)); } else { return(0.0d); } }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (!string.IsNullOrEmpty(value) && !Pattern.IsMatch(value)) { failures.Add(new ValidationFailure(nameof(Matches), $"Node [{xpath.Expression}] doesn't match pattern [{Pattern}]. Value: [{value}]")); } return(new ValidationResult(failures)); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); var expected = evaluate.Evaluate <string>(Expected); if (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(expected) && value != expected) { failures.Add(new ValidationFailure(nameof(Required), $"Node [{xpath.Expression}] is different from [{Expected.Expression}]. Actual: [{value}], Expected: [{expected}]")); } return(new ValidationResult(failures)); }
/// <summary> /// Evaluate the results /// </summary> /// <param name="studentId"></param> /// <param name="courseResults"></param> /// <returns></returns> public string Evaluate(string studentId, int[] courseResults) { var result = ""; try { IEvaluate command = (IEvaluate)Activator.GetObject(typeof(IEvaluate), $"tcp://{_host}:{_port}/{nameof(Evaluate)}"); result = command.Run(studentId, courseResults); } catch (SocketException ex) { return("There was an error doing evaluation."); } return(result); }
public ValidationResult IsValid(XPath xpath, string value, IEvaluate evaluate) { var failures = new List <ValidationFailure>(); if (!string.IsNullOrEmpty(value)) { var isInValues = Values.Any(t => t.Key == value); if (!isInValues) { failures.Add(new ValidationFailure(nameof(Required), $"Node [{xpath.Expression}] isn't in the allowed values. Value: [{value}]")); } } return(new ValidationResult(failures)); }
static void Main() { Faculty mrLin = new Faculty("2004034", "林立"); Faculty msYang = new Faculty("2002010", "杨雪梅"); Faculty mrHuang = new Faculty("2011044", "黄至辉"); Student girl = new Student("2190757001", "李四"); IEvaluate[] audiences = new IEvaluate[] { msYang, mrHuang, girl }; //对象的类型为接口(数组); OpenLesson oop = new OpenLesson() { Lecturer = mrLin, Audiences = audiences }; oop.Evaluate(); Read(); }
public LogicText(XmlNode node, Dictionary <string, ExpressionConstructorInfo> expressionConstructorInfos) : base(node) { XmlAttribute text = node.Attributes ["text"]; if (text != null) { if (node.ChildNodes.Count > 0) { throw new Exception("Cannot define both text attribute and expression"); } this.Text = new Constant(text.Value); } else { this.Text = new Expression(node.ChildNodes [0], expressionConstructorInfos); } }
/// <summary> /// Lazy indexer. /// </summary> public new T this[int index] { get { var underlyingItem = this.collection[index]; IEvaluate itemLazy = underlyingItem as IEvaluate; if (itemLazy != null && (!itemLazy.IsEvaluated)) { itemLazy.Evaluate(); } // return evaluated items return(underlyingItem); } set { throw new NotImplementedException(); } }
public StandardCalculator( IInputBuffer buffer, IOperatorLookup lookup, IUnitConverter unitConverter, IOperatorConverter operatorConverter, IExpressionBuilder builder, IExpressionParser parser, IEvaluate evaluator, IMemoryStorage memory ) : base(buffer) { Lookup = lookup; UnitConverter = unitConverter; OperatorConverter = operatorConverter; Builder = builder; Parser = parser; Evaluator = evaluator; Memory = memory; }
/// <summary> /// Lazy indexer. /// </summary> public new T this[int index] { get { var underlyingItem = this.lazifiedCollection[index]; IEvaluate itemLazy = underlyingItem as IEvaluate; if (itemLazy != null) { if (!itemLazy.IsEvaluated) { itemLazy.Evaluate(); } } // return item, evaluated if it was IEvaluate return(underlyingItem); } set { throw new NotImplementedException(); } }
public void Setup() { buffer = new InputBuffer(); lookup = new OperatorLookup(); unitConverter = new AngleConverter(); operatorConverter = new OperatorConverter(lookup.Operators, lookup.Unary); parenthesizer = new Parenthesizer(lookup.Precedence); builder = new ExpressionBuilder(parenthesizer); parser = new ExpressionParser(operatorConverter); evaluator = new Evaluator(unitConverter, operatorConverter, lookup); memory = new MemoryStorage(); calculator = new ScientificCalculator( buffer, lookup, unitConverter, operatorConverter, builder, parser, evaluator, memory ); }
public LogicCondition(XmlNode node, CreateLogicVessel vessel, Dictionary <string, ExpressionConstructorInfo> expressionConstructorInfos) : base(node) { this.Condition = new Expression(node.ChildNodes [0], expressionConstructorInfos); this.TrueLogicList = (LogicList)vessel.CreateLogic(node.ChildNodes [1].ChildNodes [0]); this.FalseLogicList = (LogicList)vessel.CreateLogic(node.ChildNodes [2].ChildNodes [0]); }
public NumericRouletteWheel(IEvaluate <double> evaluator, IFitness <double> fitness) : base(evaluator, fitness) { }
public EvalGenome(IEvaluate <T> root) { SetRoot(root); }
public Evaluate() { dal = DataAccess.CreateEvaluate(); }
public RouletteWheel(IEvaluate <T> evaluator, IFitness <T> fitness) { Evaluator = evaluator; Fitness = fitness; }
protected EvalGenome <T> Create(IEvaluate <T> root, (string message, string data) origin)
public NumericalRound05(IEvaluate number) { this.number = number; }
/// <summary> /// Wraps an evaluatable expression in a new compound expression. /// </summary> /// <param name="expression"></param> /// <returns></returns> internal static AndExpressionGroup <TSource> Begin(IEvaluate <TSource> expression) { return(new AndExpressionGroup <TSource>(expression is TruthyExpressionWrapper <TSource>?((TruthyExpressionWrapper <TSource>)expression).Inner: expression)); }
internal AndExpressionGroup(IEvaluate <TSource> expression) { AddExpression(expression); }
/// <summary> /// Adds a new expression to evaluate. /// </summary> /// <param name="expression"></param> protected internal LogicalExpressionGroup <TSource> AddExpression(IEvaluate <TSource> expression) { expressions.Add(expression); return(this); }
internal LogicalExpression <TSource> And(IEvaluate <TSource> expression) { return((this as AndExpressionGroup <TSource> ?? AndExpressionGroup <TSource> .Begin(this)).AddExpression(expression)); }
internal TruthyExpressionWrapper(IEvaluate <TSource> inner) { Inner = inner; }