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


C# IndentedStringBuilder.Indent方法代码示例

本文整理汇总了C#中AutoRest.Core.Utilities.IndentedStringBuilder.Indent方法的典型用法代码示例。如果您正苦于以下问题:C# IndentedStringBuilder.Indent方法的具体用法?C# IndentedStringBuilder.Indent怎么用?C# IndentedStringBuilder.Indent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AutoRest.Core.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:jhancock93,项目名称: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:jhancock93,项目名称:autorest,代码行数:7,代码来源:IndentedStringBuilderTests.cs

示例3: TransformPagingGroupedParameter

 protected override void TransformPagingGroupedParameter(IndentedStringBuilder builder, AzureMethodTemplateModel nextMethod, bool filterRequired = false)
 {
     if (this.InputParameterTransformation.IsNullOrEmpty() || nextMethod.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 && !groupedType.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:jhancock93,项目名称: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:garimakhulbe,项目名称:autorest,代码行数:10,代码来源:ClientModelExtensions.cs

示例5: BuildInputParameterMappings

        /// <summary>
        /// Build parameter mapping from parameter grouping transformation.
        /// </summary>
        /// <returns></returns>
        public virtual string BuildInputParameterMappings()
        {
            var builder = new IndentedStringBuilder("  ");
            if (InputParameterTransformation.Count > 0)
            {
                builder.Indent();
                foreach (var transformation in InputParameterTransformation)
                {
                    if (transformation.OutputParameter.Type is CompositeType &&
                        transformation.OutputParameter.IsRequired)
                    {
                        builder.AppendLine("{0} = {1}.new",
                            transformation.OutputParameter.Name,
                            transformation.OutputParameter.Type.Name);
                    }
                    else
                    {
                        builder.AppendLine("{0} = nil", transformation.OutputParameter.Name);
                    }
                }
                foreach (var transformation in InputParameterTransformation)
                {
                    builder.AppendLine("unless {0}", BuildNullCheckExpression(transformation))
                           .AppendLine().Indent();
                    var outputParameter = transformation.OutputParameter;
                    if (transformation.ParameterMappings.Any(m => !string.IsNullOrEmpty(m.OutputParameterProperty)) &&
                        transformation.OutputParameter.Type is CompositeType)
                    {
                        //required outputParameter is initialized at the time of declaration
                        if (!transformation.OutputParameter.IsRequired)
                        {
                            builder.AppendLine("{0} = {1}.new",
                                transformation.OutputParameter.Name,
                                transformation.OutputParameter.Type.Name);
                        }
                    }

                    foreach (var mapping in transformation.ParameterMappings)
                    {
                        builder.AppendLine("{0}{1}", transformation.OutputParameter.Name, mapping);
                    }

                    builder.Outdent().AppendLine("end");
                }
            }
            return builder.ToString();
        }
开发者ID:garimakhulbe,项目名称:autorest,代码行数:51,代码来源:MethodTemplateModel.cs


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