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


C# IExpression.GetText方法代码示例

本文整理汇总了C#中IExpression.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# IExpression.GetText方法的具体用法?C# IExpression.GetText怎么用?C# IExpression.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IExpression的用法示例。


在下文中一共展示了IExpression.GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCondition

    /// <summary>
    /// Gets the condition.
    /// </summary>
    /// <param name="leftOperand">The left operand.</param>
    /// <param name="operatorSign">The operator sign.</param>
    /// <param name="rightOperand">The right operand.</param>
    /// <returns></returns>
    private ICSharpExpression GetCondition(IExpression leftOperand, string operatorSign, IExpression rightOperand)
    {
      switch (operatorSign)
      {
        case "<":
          operatorSign = ">=";
          break;
        case ">":
          operatorSign = "<=";
          break;
        case "<=":
          operatorSign = ">";
          break;
        case ">=":
          operatorSign = "<";
          break;
      }

      return this.provider.ElementFactory.CreateExpression(string.Format("{0} {1} {2}", leftOperand.GetText(), operatorSign, rightOperand.GetText()));
    }
开发者ID:dbremner,项目名称:Resharper.UtilityPack,代码行数:27,代码来源:ReverseForLoop.cs

示例2: Handle

    public static ExpressionDescriptor Handle(IExpression expression, Dictionary<string, string> scopeParameters)
    {
      var invocationExpression = expression as IInvocationExpression;
      if (invocationExpression != null)
      {
        return new InvocationExpression().Handle(invocationExpression, scopeParameters);
      }

      var referenceExpression = expression as IReferenceExpression;
      if (referenceExpression != null)
      {
        return new ReferenceExpression().Handle(referenceExpression, scopeParameters);
      }

      var binaryExpression = expression as IBinaryExpression;
      if (binaryExpression != null)
      {
        return new BinaryExpression().Handle(binaryExpression, scopeParameters);
      }

      var isExpression = expression as IIsExpression;
      if (isExpression != null)
      {
        return new IsExpression().Handle(isExpression, scopeParameters);
      }

      var asExpression = expression as IAsExpression;
      if (asExpression != null)
      {
        return new AsExpression().Handle(asExpression, scopeParameters);
      }

      var castExpression = expression as ICastExpression;
      if (castExpression != null)
      {
        return new CastExpression().Handle(castExpression, scopeParameters);
      }

      var unaryOperatorExpression = expression as IUnaryOperatorExpression;
      if (unaryOperatorExpression != null)
      {
        return new UnaryOperatorExpression().Handle(unaryOperatorExpression, scopeParameters);
      }

      var parenthesizedExpression = expression as IParenthesizedExpression;
      if (parenthesizedExpression != null)
      {
        return new ParenthesizedExpression().Handle(parenthesizedExpression, scopeParameters);
      }

      var thisExpression = expression as IThisExpression;
      if (thisExpression != null)
      {
        return new ThisExpression().Handle(thisExpression, scopeParameters);
      }

      var creationExpression = expression as IObjectCreationExpression;
      if (creationExpression != null)
      {
        return new CreationExpression().Handle(creationExpression, scopeParameters);
      }

      var result = new ExpressionDescriptor
      {
        Template = expression.GetText()
      };

      return result;
    }
开发者ID:JakobChristensen,项目名称:Resharper.PredictiveCodeSuggestions,代码行数:69,代码来源:ExpressionTemplateBuilder.cs


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