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


C# IndentedStringBuilder.AppendLine方法代码示例

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


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

示例1: GetModelsRequiredFiles

        public string GetModelsRequiredFiles()
        {
            var sb = new IndentedStringBuilder();

            this.GetOrderedModels().Where(m => !m.Extensions.ContainsKey(ExternalExtension)).ForEach(model => sb.AppendLine("{0}",
                this.GetRequiredFormat("models/" + RubyCodeNamer.UnderscoreCase(model.Name) + ".rb")));

            this.EnumTypes.ForEach(enumType => sb.AppendLine(this.GetRequiredFormat("models/" + RubyCodeNamer.UnderscoreCase(enumType.Name) + ".rb")));

            return sb.ToString();
        }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:11,代码来源:RequirementsTemplateModel.cs

示例2: DeserializePollingResponse

        /// <summary>
        /// Generates Ruby code in form of string for deserializing polling response.
        /// </summary>
        /// <param name="variableName">Variable name which keeps the response.</param>
        /// <param name="type">Type of response.</param>
        /// <returns>Ruby code in form of string for deserializing polling response.</returns>
        public string DeserializePollingResponse(string variableName, IType type)
        {
            var builder = new IndentedStringBuilder("  ");

            string serializationLogic = type.DeserializeType(this.Scope, variableName);
            return builder.AppendLine(serializationLogic).ToString();
        }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:13,代码来源:AzureMethodTemplateModel.cs

示例3: ConstructModelMapper

 public override string ConstructModelMapper()
 {
     var modelMapper = this.ConstructMapper(SerializedName, null, true, true);
     var builder = new IndentedStringBuilder("  ");
     builder.AppendLine("return {{{0}}};", modelMapper);
     return builder.ToString();
 }
开发者ID:RemcoHulshoff,项目名称:autorest,代码行数:7,代码来源:PageTemplateModel.cs

示例4: DeserializeProperty

        /// <summary>
        /// Generates code for model deserialization.
        /// </summary>
        /// <param name="variableName">Variable deserialize model from.</param>
        /// <param name="type">The type of the model.</param>
        /// <returns>The code for вуserialization in string format.</returns>
        public override string DeserializeProperty(string variableName, IType type)
        {
            var builder = new IndentedStringBuilder("  ");

            string serializationLogic = type.AzureDeserializeType(this.Scope, variableName);
            return builder.AppendLine(serializationLogic).ToString();
        }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:13,代码来源:AzureModelTemplateModel.cs

示例5: GetOperationsRequiredFiles

 public string GetOperationsRequiredFiles()
 {
     var sb = new IndentedStringBuilder();
     this.MethodGroups.ForEach(method => sb.AppendLine("{0}",
         this.GetRequiredFormat(RubyCodeNamer.UnderscoreCase(method) + ".rb")));
     return sb.ToString();
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:7,代码来源:RequirementsTemplateModel.cs

示例6: 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

示例7: AppendMultilinePreservesIndentation

        public void AppendMultilinePreservesIndentation()
        {
            IndentedStringBuilder sb = new IndentedStringBuilder();
            var expected = string.Format("start{0}    line2{0}        line31{0}        line32{0}", Environment.NewLine);
            var result = sb
                .AppendLine("start").Indent()
                    .AppendLine("line2").Indent()
                    .AppendLine(string.Format("line31{0}line32", Environment.NewLine));
            Assert.Equal(expected, result.ToString());

            sb = new IndentedStringBuilder();
            expected = string.Format("start{0}    line2{0}        line31{0}        line32{0}", Environment.NewLine);
            result = sb
                .AppendLine("start").Indent()
                    .AppendLine("line2").Indent()
                    .AppendLine(string.Format("line31{0}line32", Environment.NewLine));
            Assert.Equal(expected, result.ToString());
        }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:18,代码来源:IndentedStringBuilderTests.cs

示例8: AppendMultilinePreservesIndentation

        public void AppendMultilinePreservesIndentation()
        {
            IndentedStringBuilder sb = new IndentedStringBuilder();
            var expected = "start\r\n    line2\r\n        line31\n        line32\r\n";
            var result = sb
                .AppendLine("start").Indent()
                    .AppendLine("line2").Indent()
                    .AppendLine("line31\nline32");
            Assert.Equal(expected, result.ToString());

            sb = new IndentedStringBuilder();
            expected = "start\r\n    line2\r\n        line31\r\n        line32\r\n";
            result = sb
                .AppendLine("start").Indent()
                    .AppendLine("line2").Indent()
                    .AppendLine("line31\r\nline32");
            Assert.Equal(expected, result.ToString());
        }
开发者ID:juvchan,项目名称:autorest,代码行数:18,代码来源:IndentedStringBuilderTests.cs

示例9: AddIndividualResponseHeader

        public virtual string AddIndividualResponseHeader(HttpStatusCode? code)
        {
            IType headersType = null;

            if (HasResponseHeader)
            {
                if (code != null)
                {
                    headersType = this.ReturnType.Headers;
                }
                else
                {
                    headersType = this.Responses[code.Value].Headers;
                }
            }

            var builder = new IndentedStringBuilder("    ");
            if (headersType == null)
            {
                if (code == null)
                {
                    builder.AppendLine("header_dict = {}");
                }
                else
                {
                    return string.Empty;
                }
            }
            else
            {
                builder.AppendLine("header_dict = {").Indent();
                AddHeaderDictionary(builder, (CompositeType)headersType);
                builder.Outdent().AppendLine("}");
            }
            return builder.ToString();
        }
开发者ID:CamSoper,项目名称:autorest,代码行数:36,代码来源:MethodTemplateModel.cs

示例10: AddResponseHeader

 public virtual string AddResponseHeader()
 {
     if (HasResponseHeader)
     {
         var builder = new IndentedStringBuilder("    ");
         builder.AppendLine("client_raw_response.add_headers(header_dict)");
         return builder.ToString();
     }
     else
     {
         return string.Empty;
     }
 }
开发者ID:CamSoper,项目名称:autorest,代码行数:13,代码来源:MethodTemplateModel.cs

示例11: BuildUrlPath

        public virtual string BuildUrlPath(string variableName)
        {
            var builder = new IndentedStringBuilder("    ");

            var pathParameterList = this.LogicalParameters.Where(p => p.Location == ParameterLocation.Path).ToList();
            if (pathParameterList.Any())
            {
                builder.AppendLine("path_format_arguments = {").Indent();

                for (int i = 0; i < pathParameterList.Count; i ++)
                {
                    builder.AppendLine("'{0}': {1}{2}{3}",
                        pathParameterList[i].SerializedName,
                        BuildSerializeDataCall(pathParameterList[i], "url"),
                        pathParameterList[i].IsRequired ? string.Empty :
                            string.Format(CultureInfo.InvariantCulture, "if {0} else ''", pathParameterList[i].Name),
                        i == pathParameterList.Count-1 ? "" : ",");
                }

                builder.Outdent().AppendLine("}");
                builder.AppendLine("{0} = {0}.format(**path_format_arguments)", variableName);
            }

            return builder.ToString();
        }
开发者ID:CamSoper,项目名称:autorest,代码行数:25,代码来源:MethodTemplateModel.cs

示例12: CheckNull

 public static string CheckNull(string valueReference, string executionBlock)
 {
     var sb = new IndentedStringBuilder();
     sb.AppendLine("if ({0} != null)", valueReference)
         .AppendLine("{").Indent()
             .AppendLine(executionBlock).Outdent()
         .AppendLine("}");
     return sb.ToString();
 }
开发者ID:tonytang-microsoft-com,项目名称:autorest,代码行数:9,代码来源:ClientModelExtensions.cs

示例13: BuildQueryParameterArray

        /// <summary>
        /// Genrate code to build an array of query parameter strings in a variable named 'queryParameters'.  The 
        /// array should contain one string element for each query parameter of the form 'key=value'
        /// </summary>
        /// <param name="builder">The stringbuilder for url construction</param>
        protected virtual void BuildQueryParameterArray(IndentedStringBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            builder.AppendLine("var queryParameters = [];");
            foreach (var queryParameter in LogicalParameters
                .Where(p => p.Location == ParameterLocation.Query))
            {
                var queryAddFormat = "queryParameters.push('{0}=' + encodeURIComponent({1}));";
                if (queryParameter.SkipUrlEncoding())
                {
                    queryAddFormat = "queryParameters.push('{0}=' + {1});";
                }
                if (!queryParameter.IsRequired)
                {
                    builder.AppendLine("if ({0} !== null && {0} !== undefined) {{", queryParameter.Name)
                        .Indent()
                        .AppendLine(queryAddFormat,
                            queryParameter.SerializedName, queryParameter.GetFormattedReferenceValue()).Outdent()
                        .AppendLine("}");
                }
                else
                {
                    builder.AppendLine(queryAddFormat,
                        queryParameter.SerializedName, queryParameter.GetFormattedReferenceValue());
                }
            }
        }
开发者ID:RemcoHulshoff,项目名称:autorest,代码行数:36,代码来源:MethodTemplateModel.cs

示例14: RemoveDuplicateForwardSlashes

        /// <summary>
        /// Generate code to remove duplicated forward slashes from a URL in code
        /// </summary>
        /// <param name="urlVariableName"></param>
        /// <returns></returns>
        public virtual string RemoveDuplicateForwardSlashes(string urlVariableName)
        {
            var builder = new IndentedStringBuilder("  ");

            builder.AppendLine("// trim all duplicate forward slashes in the url");
            builder.AppendLine("var regex = /([^:]\\/)\\/+/gi;");
            builder.AppendLine("{0} = {0}.replace(regex, '$1');", urlVariableName);
            return builder.ToString();
        }
开发者ID:RemcoHulshoff,项目名称:autorest,代码行数:14,代码来源:MethodTemplateModel.cs

示例15: ConstructPropertyDocumentation

 public static string ConstructPropertyDocumentation(string propertyDocumentation)
 {
     var builder = new IndentedStringBuilder("  ");
     return builder.AppendLine(propertyDocumentation)
                   .AppendLine(" * ").ToString();
 }
开发者ID:DebugOfTheRoad,项目名称:autorest,代码行数:6,代码来源:ModelTemplateModel.cs


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