public Filter(string filterText, Expression filter)
        {
            if (string.IsNullOrEmpty(filterText))
                throw new ArgumentNullException("filterText");

            Hash = (filter == null) ? 0 : filter.GetHashCode();
        }
        public ExpressionVertex(Expression expression)
            : this()
        {
            FullName = expression.ToString();

            var fullTextFormatter = new FullTextFormatter();
            var shortTextFormatter = new ShortTextFormatter();

            FullName = fullTextFormatter.Format(expression);
            ShortName = shortTextFormatter.Format(expression);

            _expressionHashCode = expression.GetHashCode();
        }
		private static bool TryGetMemberValue(Expression expression, out object value, Dictionary<int, bool> visited)
		{
			if (expression == null)
			{
				// used for static fields, etc
				value = null;
				return true;
			}
			// Mark this node as visited (processed)
			int expressionHash = expression.GetHashCode();
			if (!visited.ContainsKey(expressionHash))
			{
				visited.Add(expressionHash, true);
			}
			// Get Member Value, recurse if necessary
			switch (expression.NodeType)
			{
				case ExpressionType.Constant:
					value = ((ConstantExpression)expression).Value;
					return true;
				case ExpressionType.MemberAccess:
					var me = (MemberExpression)expression;
					object target;
					if (TryGetMemberValue(me.Expression, out target, visited))
					{
						// instance target
						switch (me.Member.MemberType)
						{
							case MemberTypes.Field:
								value = ((FieldInfo)me.Member).GetValue(target);
								return true;
							case MemberTypes.Property:
								value = ((PropertyInfo)me.Member).GetValue(target, null);
								return true;
						}
					}
					break;
			}
			// Could not retrieve value
			value = null;
			return false;
		}
 /// <summary>
 /// Constructor with an <see cref="Expression"/> and an <see cref="ExpressionConverter"/>.
 /// </summary>
 /// <param name="expression">The original, not serializable <see cref="Expression"/>.</param>
 /// <param name="expConverter">The <see cref="ExpressionConverter"/> to convert contained <see cref="Expression">Expressions</see>.</param>
 protected SerializableExpression(Expression expression, ExpressionConverter expConverter)
     : this(expression.NodeType, expression.Type, expConverter)
 {
     HashCode = expression.GetHashCode();
 }
        internal bool ContainsExpression(Expression ex)
        {
            if (ex == null)
                return Filters.Any(x => x.Hash == 0);

            int h = ex.GetHashCode();
            return Filters.Any(x => x.Hash == h);
        }