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