當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。