本文整理汇总了C#中System.Linq.Expressions.Expression.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.ToString方法的具体用法?C# Expression.ToString怎么用?C# Expression.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckExpression
public static void CheckExpression(Expression<Func<Boolean>> expression)
{
if (!expression.Compile()())
{
throw new MalformedException(string.Concat("Bad file format, expecting ", expression.ToString().Replace("() => ", string.Empty)));
}
}
示例2: Visit
public void Visit(TreeView tv, Expression ex)
{
this.tv = tv;
root = tv.Nodes.Add(ex.ToString());
nodeStack.Push(root);
Visit(ex);
}
示例3: SimpleCheck
/// <summary>
/// 式木の構造が一致してれば、少なくとも ToString の結果は一致するので、
/// それで2つの式木の一致性を判定。
/// </summary>
static void SimpleCheck(Expression e1, Expression e2, bool verbose)
{
if (e1.ToString() != e2.ToString())
{
Console.Write("not match: {0}, {1}\n", e1, e2);
}
}
示例4: ExtractRootObjectName
internal static string ExtractRootObjectName(Expression e)
{
if (e.NodeType == ExpressionType.Lambda)
return ((LambdaExpression)e).Parameters[0].Name;
var path = e.ToString();
return new string(path.TakeWhile(c => char.IsLetterOrDigit(c)).ToArray());
}
示例5: Visit
public override Expression Visit(Expression node)
{
// If we're not processed expression by special method
// lets use base ToString implementation.
if (node != null)
_rep = node.ToString();
return base.Visit(node);
}
示例6: VisitExtension
protected override Expression VisitExtension (Expression expression)
{
ArgumentUtility.CheckNotNull ("expression", expression);
if (expression.CanReduce)
return base.VisitExtension (expression);
return Expression.Parameter (expression.Type, expression.ToString());
}
示例7: Assert
public static void Assert(Expression<Func<bool>> assertion)
{
Func<bool> compiled = assertion.Compile();
bool evaluatedValue = compiled();
if (!evaluatedValue)
{
throw new InvalidOperationException(
string.Format("'{0}' is not met.", Normalize(assertion.ToString())));
}
}
示例8: GetRightMostMember
internal static MemberExpression GetRightMostMember(Expression e)
{
if (e is MemberExpression)
return (MemberExpression)e;
if (e is MethodCallExpression)
return GetRightMostMember(((MethodCallExpression)e).Object);
throw new SisoDbException(ExceptionMessages.ExpressionUtils_GetRightMostMember_NoMemberFound
.Inject(e.ToString()));
}
示例9: SetResult
public void SetResult(Expression r)
{
if (r == null)
throw new ArgumentNullException("Cannot set the result to be null");
ResultValue = r;
Debug.WriteLine("SetResult: {0}{1}", r.ToString(), "");
if (r is IDeclaredParameter)
ResultValueAsVaraible = r as IDeclaredParameter;
}
示例10: GetCacheKey
public CacheKey GetCacheKey(Expression expression)
{
// use the string representation of the expression for the cache key
string key = expression.ToString();
// the key is potentially very long, so use an md5 fingerprint
// (fine if the query result data isn't critically sensitive)
key = ToMd5Fingerprint(key);
return CacheKey.Create(null, key); ;
}
示例11: ExpressionToString
internal static string ExpressionToString(DataServiceContext context, Expression e)
{
ExpressionWriter ew = new ExpressionWriter(context);
string serialized = ew.Translate(e);
if (ew.cantTranslateExpression)
{
throw new NotSupportedException(Strings.ALinq_CantTranslateExpression(e.ToString()));
}
return serialized;
}
示例12: Parse
public static string Parse(Expression expressionBody)
{
var body = expressionBody.ToString();
var cut = body.IndexOf(").");
var sentence = body.Substring(cut + 1, body.Length - cut - 1).Replace(")", " ").Replace(".", " ").Replace("(", " ").Replace(" ", " ").Trim().Replace("_", " ").Replace("\"", " ");
while (sentence.Contains(" ")) sentence = sentence.Replace(" ", " ");
return sentence.Trim();
}
示例13: FindResolution
public override Expression FindResolution(OperatorType op, Expression prop, Expression val)
{
if (op == OperatorType.Like)
{
string s = val.ToString().Trim('"').Replace('?', '_').Replace('*', '%');
return Expression.GreaterThan(Expression.Call(typeof(SqlFunctions).GetMethod("PatIndex"), Expression.Constant(s, s.GetType()), prop), Expression.Constant(0, typeof(Nullable<int>)));
}
else
{
return base.FindResolution(op, prop, val);
}
}
示例14: DescribeExpression
private static string DescribeExpression(Expression exp)
{
if (exp is MemberExpression || exp is MethodCallExpression)
{
return GetName(exp);
}
if (exp is ConstantExpression)
{
return ((ConstantExpression) exp).Value.ToString();
}
return exp.ToString();
}
示例15: 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();
}