当前位置: 首页>>代码示例>>C#>>正文


C# Expression.ToString方法代码示例

本文整理汇总了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)));
     }
 }
开发者ID:redrocktx,项目名称:shellify,代码行数:7,代码来源:FormatChecker.cs

示例2: Visit

 public void Visit(TreeView tv, Expression ex)
 {
     this.tv = tv;
     root = tv.Nodes.Add(ex.ToString());
     nodeStack.Push(root);
     Visit(ex);
 }
开发者ID:mbsky,项目名称:dotnetmarcheproject,代码行数:7,代码来源:DumpVisitor.cs

示例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);
			}
		}
开发者ID:ufcpp,项目名称:UfcppSample,代码行数:11,代码来源:ExpressionTest.cs

示例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());
        }
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:8,代码来源:ExpressionTreeUtils.cs

示例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);
        }
开发者ID:SergeyTeplyakov,项目名称:VerificationFakes,代码行数:9,代码来源:ExpressionPrinterVisitor.cs

示例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());
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:9,代码来源:FormattingExpressionVisitor.cs

示例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())));
     }
 }
开发者ID:andrewdavey,项目名称:ravendb,代码行数:10,代码来源:Guard.cs

示例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()));
        }
开发者ID:darrencauthon,项目名称:SisoDb-Provider,代码行数:11,代码来源:ExpressionTreeUtils.cs

示例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;
        }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:11,代码来源:GeneratedCode.cs

示例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); ;
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:11,代码来源:ExpressionCacheKeyGenerator.cs

示例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;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:11,代码来源:ExpressionWriter.cs

示例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();
        }
开发者ID:rajeshpillai,项目名称:NSpec,代码行数:12,代码来源:Example.cs

示例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);
     }
 }
开发者ID:koder05,项目名称:fogel-ba,代码行数:12,代码来源:SqlOperatorResolver.cs

示例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();
        }
开发者ID:davidmfoley,项目名称:bickle,代码行数:13,代码来源:SpecDescriber.cs

示例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();
        }
开发者ID:vik-borisov,项目名称:VikExpressionTreeVisualizer,代码行数:13,代码来源:ExpressionVertex.cs


注:本文中的System.Linq.Expressions.Expression.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。