本文整理汇总了C#中System.Linq.Expressions.Expression.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.GetHashCode方法的具体用法?C# Expression.GetHashCode怎么用?C# Expression.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.GetHashCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Filter
public Filter(string filterText, Expression filter)
{
if (string.IsNullOrEmpty(filterText))
throw new ArgumentNullException("filterText");
Hash = (filter == null) ? 0 : filter.GetHashCode();
}
示例2: ExpressionVertex
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();
}
示例3: TryGetMemberValue
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;
}
示例4: SerializableExpression
/// <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();
}
示例5: ContainsExpression
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);
}