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


C# IndentedStringBuilder.Indent方法代码示例

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


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

示例1: AppendWorksWithNull

 public void AppendWorksWithNull()
 {
     IndentedStringBuilder sb = new IndentedStringBuilder();
     var expected = "";
     var result = sb.Indent().Append(null);
     Assert.Equal(expected, result.ToString());
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:7,代码来源:IndentedStringBuilderTests.cs

示例2: AppendDoesNotAddIndentation

 public void AppendDoesNotAddIndentation(string input)
 {
     IndentedStringBuilder sb = new IndentedStringBuilder();
     var expected = input;
     var result = sb.Indent().Append(input);
     Assert.Equal(expected, result.ToString());
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:7,代码来源:IndentedStringBuilderTests.cs

示例3: TransformPagingGroupedParameter

 protected override void TransformPagingGroupedParameter(IndentedStringBuilder builder, AzureMethodTemplateModel nextMethod, bool filterRequired = false)
 {
     if (this.InputParameterTransformation.IsNullOrEmpty())
     {
         return;
     }
     var groupedType = this.InputParameterTransformation.First().ParameterMappings[0].InputParameter;
     var nextGroupType = nextMethod.InputParameterTransformation.First().ParameterMappings[0].InputParameter;
     if (nextGroupType.Name == groupedType.Name)
     {
         return;
     }
     var nextGroupTypeName = _namer.GetTypeName(nextGroupType.Name) + "Inner";
     if (filterRequired && !nextGroupType.IsRequired)
     {
         return;
     }
     if (!groupedType.IsRequired)
     {
         builder.AppendLine("{0} {1} = null;", nextGroupTypeName, nextGroupType.Name.ToCamelCase());
         builder.AppendLine("if ({0} != null) {{", groupedType.Name.ToCamelCase());
         builder.Indent();
         builder.AppendLine("{0} = new {1}();", nextGroupType.Name.ToCamelCase(), nextGroupTypeName);
     }
     else
     {
         builder.AppendLine("{1} {0} = new {1}();", nextGroupType.Name.ToCamelCase(), nextGroupTypeName);
     }
     foreach (var outParam in nextMethod.InputParameterTransformation.Select(t => t.OutputParameter))
     {
         builder.AppendLine("{0}.with{1}({2}.{3}());", nextGroupType.Name.ToCamelCase(), outParam.Name.ToPascalCase(), groupedType.Name.ToCamelCase(), outParam.Name.ToCamelCase());
     }
     if (!groupedType.IsRequired)
     {
         builder.Outdent().AppendLine(@"}");
     }
 }
开发者ID:tdjastrzebski,项目名称:autorest,代码行数:37,代码来源:AzureFluentMethodTemplateModel.cs

示例4: ConstructValidationCheck

        private static IndentedStringBuilder ConstructValidationCheck(IndentedStringBuilder builder, string errorMessage, string valueReference, string typeName)
        {
            var escapedValueReference = valueReference.EscapeSingleQuotes();
            var lowercaseTypeName = typeName.ToLower(CultureInfo.InvariantCulture);

            return builder.Indent()
                            .AppendLine(errorMessage, escapedValueReference, lowercaseTypeName)
                          .Outdent()
                          .AppendLine("}");
        }
开发者ID:jkonecki,项目名称:autorest,代码行数:10,代码来源:ClientModelExtensions.cs

示例5: TransformPagingGroupedParameter

 private void TransformPagingGroupedParameter(IndentedStringBuilder builder, AzureMethodTemplateModel nextMethod)
 {
     if (this.InputParameterTransformation.IsNullOrEmpty())
     {
         return;
     }
     var groupedType = this.InputParameterTransformation.FirstOrDefault().ParameterMappings[0].InputParameter;
     var nextGroupType = nextMethod.InputParameterTransformation.FirstOrDefault().ParameterMappings[0].InputParameter;
     if (nextGroupType.Name == groupedType.Name)
     {
         return;
     }
     if (!groupedType.IsRequired)
     {
         builder.AppendLine("{0} {1} = null;", nextGroupType.Name.ToPascalCase(), nextGroupType.Name.ToCamelCase());
         builder.AppendLine("if ({0} != null) {{", groupedType.Name.ToCamelCase());
         builder.Indent();
         builder.AppendLine("{0} = new {1}();", nextGroupType.Name.ToCamelCase(), nextGroupType.Name.ToPascalCase());
     }
     else
     { 
         builder.AppendLine("{1} {0} = new {1}();", nextGroupType.Name.ToCamelCase(), nextGroupType.Name.ToPascalCase());
     }
     foreach (var outParam in nextMethod.InputParameterTransformation.Select(t => t.OutputParameter))
     {
         builder.AppendLine("{0}.set{1}({2}.get{1}());", nextGroupType.Name.ToCamelCase(), outParam.Name.ToPascalCase(), groupedType.Name.ToCamelCase());
     }
     if (!groupedType.IsRequired)
     {
         builder.Outdent().AppendLine(@"}");
     }
 }
开发者ID:JamesTryand,项目名称:autorest,代码行数:32,代码来源:AzureMethodTemplateModel.cs


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