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


C# LiteralExpressionSyntax.ToString方法代码示例

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


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

示例1: VisitLiteralExpression

        public override SyntaxNode VisitLiteralExpression(LiteralExpressionSyntax node)
        {
            if (node.IsKind(SyntaxKind.StringLiteralExpression)
                && node.ToString().IndexOf('\n') >= 0)
            {
                node = node.WithAdditionalAnnotations(LayoutAnnotations.MultiLineConstructAnnotation);
            }

            return base.VisitLiteralExpression(node);
        }
开发者ID:madelson,项目名称:MedallionCodeFormatter,代码行数:10,代码来源:MultiLineConstructAnnotator.cs

示例2: VisitLiteralExpression

 public override void VisitLiteralExpression(LiteralExpressionSyntax node)
 {
     if (node.Kind() == SyntaxKind.StringLiteralExpression)
     cb.Append("std::string(").Append(node.ToString()).Append(")");
       else
     cb.Append(node.ToString());
 }
开发者ID:ActiveMesa,项目名称:Blackmire,代码行数:7,代码来源:CppImplWalker.cs

示例3: LiteralExpression

 public static string LiteralExpression(LiteralExpressionSyntax expression)
 {
     switch (expression.CSharpKind())
     {
         //Swift doesn't use the same 'c' character literal syntax, instead you create a String and type annotate it as a Character
         case SyntaxKind.CharacterLiteralExpression:
             //this is sketch, probably shouldn't use char literals o.o
             return '"' + expression.Token.ValueText.Replace("\\'", "'").Replace("\"", "\\\"") + '"';
         default:
             return expression.ToString();
     }
 }
开发者ID:UIKit0,项目名称:SharpSwift,代码行数:12,代码来源:ExpressionSyntaxParser.cs

示例4: Go

		public static void Go(OutputWriter writer, LiteralExpressionSyntax expression, bool isConst, bool inSwitch=false)
        {
            var str = expression.ToString();


            if (str.Trim() == "null")
            {
                writer.Write("null");
                return;
            }

            if (str.StartsWith("@\""))
            {
                str = "r" + FixUpLiterals(EncodeNonAsciiCharacters(FixUpLiterals(str.Substring(1))));
                /*str = "\"" +
                      str.RemoveFromStartOfString("@\"")
                          .RemoveFromEndOfString("\"")
                          .Replace("\\", "\\\\")
                          .Replace("\"\"", "\\\"")
                          .Replace("\r\n", "\\n") + "\"";*/
            }

            var typeInfo = TypeProcessor.GetTypeInfo(expression);
            var type = typeInfo.Type;
            if (type == null)
                type = typeInfo.ConvertedType;

         

            if (type != null && type.SpecialType == SpecialType.System_String)
            {
                if (str.Contains("\\u") || str.Contains("\\x"))
               
                str = FixUpLiterals(EncodeNonAsciiCharacters(FixUpLiterals(str)));
                if (str == "null")
                {
                    if (inSwitch)
                        writer.Write("-1");
                    else
                        writer.Write("null");
                }
                else if (inSwitch)
                {
                    writer.Write(str);
                }
                else
                {
                }
                writer.Write("_S(" + str + ")");
            }
            else if (type != null && type.Name == "Nullable")//Nullable Support
            {
               
                var atype = TypeProcessor.ConvertType(type);
                writer.Write(atype + "()");
                
            }
            else
            {
                if(type.SpecialType==SpecialType.System_Boolean)
                    writer.Write(str);
                else if (type.SpecialType == SpecialType.System_Char)
                {

if(str.Contains("\\u") || str.Contains("\\x"))
                    writer.Write("cast(wchar)"+FixUpCharacterLiteral(str));
else
{
    writer.Write(str);
}
                }
                else
                {

                    //No need to convert these ... lets just put the correct suffix ourselves


                    if (typeInfo.ConvertedType != typeInfo.Type && typeInfo.ConvertedType.IsPrimitiveInteger() && typeInfo.Type.IsPrimitiveInteger())
                    {
                        writer.Write("cast({0})",TypeProcessor.ConvertType(typeInfo.ConvertedType)); //TODO: add better, less clumsy conversion
                    }

//                    //Number literals //TODO: make these convert to D Literal Suffixes
//                    var suffix = realTypeSuffixes.FirstOrDefault (j => str.EndsWith (j));
//                    if (suffix != null)
//						str = str.Replace(suffix,drealTypeSuffixes[Array.IndexOf(realTypeSuffixes,suffix)]);
//					else
//					{
//						suffix = integerTypeSuffixes.FirstOrDefault (j => str.EndsWith (j));
//						if (suffix != null)
//							str = str.Replace(suffix,dintegerTypeSuffixes[Array.IndexOf(integerTypeSuffixes,suffix)]);
//					}

                    writer.Write(str);
                }
            }


        }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:99,代码来源:WriteLiteralExpression.cs

示例5: IsNoCandidateDiagnostic

 private static bool IsNoCandidateDiagnostic(LiteralExpressionSyntax literal)
 {
     return literal.ToString() != "\"\"" ||
            literal.Ancestors().OfType<AttributeArgumentSyntax>().Any() ||
            literal.Ancestors().OfType<ParameterListSyntax>().Any();
 }
开发者ID:Vossekop,项目名称:code-cracker,代码行数:6,代码来源:UseStringEmptyAnalyzer.cs


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