Ejemplo n.º 1
0
        /// <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>
        public ExpressionObserver(object root, string expression)
        {
            Contract.Requires <ArgumentNullException>(expression != null);

            _root = root;

            if (!string.IsNullOrWhiteSpace(expression))
            {
                _node = ExpressionNodeBuilder.Build(expression);
            }

            Expression = expression;
        }
Ejemplo n.º 2
0
        /// <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>
        public ExpressionObserver(Func <object> rootGetter, string expression)
        {
            Contract.Requires <ArgumentNullException>(rootGetter != null);
            Contract.Requires <ArgumentNullException>(expression != null);

            _rootGetter = rootGetter;

            if (!string.IsNullOrWhiteSpace(expression))
            {
                _node = ExpressionNodeBuilder.Build(expression);
            }

            Expression = expression;
        }