本文整理汇总了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());
}
示例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());
}
示例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(@"}");
}
}
示例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("}");
}
示例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(@"}");
}
}