private static ExpressionNode Parse(string expression, bool enableDataValidation) { if (!string.IsNullOrWhiteSpace(expression)) { return(ExpressionNodeBuilder.Build(expression, enableDataValidation)); } else { return(new EmptyExpressionNode()); } }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionObserver"/> class. /// </summary> /// <param name="root">The root object.</param> /// <param name="expression">The expression.</param> /// <param name="enableValidation">Whether property validation should be enabled.</param> public ExpressionObserver(object root, string expression, bool enableValidation = false) { Contract.Requires <ArgumentNullException>(expression != null); _root = new WeakReference(root); _enableValidation = enableValidation; if (!string.IsNullOrWhiteSpace(expression)) { _node = ExpressionNodeBuilder.Build(expression, enableValidation); } Expression = expression; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionObserver"/> class. /// </summary> /// <param name="rootObservable">An observable which provides the root object.</param> /// <param name="expression">The expression.</param> /// <param name="enableValidation">Whether property validation should be enabled.</param> public ExpressionObserver( IObservable <object> rootObservable, string expression, bool enableValidation = false) { Contract.Requires <ArgumentNullException>(rootObservable != null); Contract.Requires <ArgumentNullException>(expression != null); _rootObservable = rootObservable; _enableValidation = enableValidation; if (!string.IsNullOrWhiteSpace(expression)) { _node = ExpressionNodeBuilder.Build(expression, enableValidation); } Expression = expression; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionObserver"/> class. /// </summary> /// <param name="rootGetter">A function which gets the root object.</param> /// <param name="expression">The expression.</param> /// <param name="update">An observable which triggers a re-read of the getter.</param> /// <param name="enableValidation">Whether property validation should be enabled.</param> public ExpressionObserver( Func <object> rootGetter, string expression, IObservable <Unit> update, bool enableValidation = false) { Contract.Requires <ArgumentNullException>(rootGetter != null); Contract.Requires <ArgumentNullException>(expression != null); Contract.Requires <ArgumentNullException>(update != null); _rootGetter = rootGetter; _update = update; _enableValidation = enableValidation; if (!string.IsNullOrWhiteSpace(expression)) { _node = ExpressionNodeBuilder.Build(expression, enableValidation); } Expression = expression; }