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


C# StringBuilder.AppendLineFormat方法代码示例

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


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

示例1: ParseStatement

		public string ParseStatement( PropertyInfo[] modelProperties, string sourceParamName)
		{
			var builder = new StringBuilder();
			builder.AppendLineFormat("if(Take>0 || Skip>0)");
			builder.AppendLine("{");
			builder.AppendLineFormat("switch(OrderField)");
			builder.AppendLine("{");
			foreach (var modelProperty in modelProperties)
			{
				if (modelProperty.PropertyType.IsValueType || modelProperty.PropertyType == typeof (string))
				{
					builder.AppendLineFormat("case \"{0}\":", modelProperty.Name);
					builder.AppendLineFormat(
						"{0}=(OrderDirection==Agile.Common.Data.OrderDirection.ASC)?{0}.OrderBy(o=>o.{1}):{0}.OrderByDescending(o=>o.{1});", sourceParamName,
						modelProperty.Name);
					builder.AppendLine("break;");
				}
				
			}
			builder.AppendLine("default:");
			builder.AppendLineFormat(
						"{0}=(OrderDirection==Agile.Common.Data.OrderDirection.ASC)?{0}.OrderBy(o=>o.{1}):{0}.OrderByDescending(o=>o.{1});", sourceParamName,
						KeyPropertyName);
			builder.AppendLine("break;");
			builder.AppendLine("}");
			builder.AppendLine("}");

			return builder.ToString();
		}
开发者ID:tianzhiyuan,项目名称:agile,代码行数:29,代码来源:PaginationAnalyzer.cs

示例2: InitializeAutoComplete

        public static string InitializeAutoComplete(this HtmlHelper html, string textBoxName, string fieldName, string url, object options, bool wrapInReady)
        {
            StringBuilder sb = new StringBuilder();
            if (wrapInReady) sb.AppendLineFormat("<script language='javascript'>");

            if (wrapInReady) sb.AppendLineFormat("$().ready(function() {{");
            sb.AppendLine();
            sb.AppendLineFormat("   $('#{0}').autocomplete('{1}', {{", textBoxName.Replace(".", "\\\\."), url);

            PropertyInfo[] properties = options.GetType().GetProperties();

            for (int i = 0; i < properties.Length; i++) {
                sb.AppendLineFormat("   {0} : {1}{2}",
                                        properties[i].Name,
                                        properties[i].GetValue(options, null),
                                        i != properties.Length - 1 ? "," : "");
            }
            sb.AppendLineFormat("   }});");
            sb.AppendLine();
            sb.AppendLineFormat("   $('#{0}').result(function(e, d, f) {{", textBoxName.Replace(".", "\\\\."));
            sb.AppendLineFormat("       $('#{0}').val(d[1]);", fieldName);
            sb.AppendLineFormat("    }});");
            sb.AppendLine();
            if (wrapInReady) sb.AppendLineFormat("}});");
            if (wrapInReady) sb.AppendLineFormat("</script>");
            return sb.ToString();
        }
开发者ID:mdrubin,项目名称:codevoyeur-samples,代码行数:27,代码来源:JQueryExtensions.cs

示例3: ParseStatement

		public string ParseStatement(AnalyzeContext context)
		{
			Init();
			/**
             *      ***Navigation
             *      if(concreteQuery.UserQuery != null)
             *     {
             *          {
             *              var naviQuery = concreteQuery.UserQuery;
             *              if(naviQuery.Id != null){
             *                  source = source.Where(t=>t.User.Id == naviQuery.Id);
             *              }
			 *              if(naviQuery.RoleQuery != null){
			 *					var naviQuery_2 = naviQuery.RoleQuery;
			 *					
			 *              }
             *          }
             *      }
             */
			if (context.Depth >= MaxDepth) return "";
			var queryPropertyName = context.QueryProperty.Name;
			var modelPropertyName = context.ModelProperty.Name;
			var naviQueryParam = "naviQuery_" + (context.Depth + 1);
			var builder = new StringBuilder();
			builder.AppendLineFormat("if({0} != null)", context.QueryParamName+"."+queryPropertyName);
			builder.AppendLine("{");
			builder.AppendLineFormat("var {0}={1}.{2};", naviQueryParam, context.QueryParamName, queryPropertyName);
			var naviQueryProperties = context.QueryProperty.PropertyType.GetProperties();
			var naviModelProperties = context.ModelProperty.PropertyType.GetProperties();
			foreach (var naviQueryProperty in naviQueryProperties)
			{
				var naviContext = new AnalyzeContext()
					{
						Depth = context.Depth + 1,
						QueryProperty = naviQueryProperty,
						SourceParamName = context.SourceParamName,
						QueryParamName = naviQueryParam,
						Navigations = context.Navigations.Concat(new[] {context.ModelProperty.Name}).ToArray()
					};
				for (var index = 0; index < Analyzers.Length; index++)
				{
					var naviAnalyzer = Analyzers[index];
					var naviModelProperty = naviAnalyzer.FindAttachedModelProperty(naviQueryProperty, naviModelProperties);
					if (naviModelProperty == null) continue;
					naviContext.ModelProperty = naviModelProperty;
					var naviStatement = naviAnalyzer.ParseStatement(naviContext);
					queues[index].Add(naviStatement);
				}
				
			}
			for (var index = 0; index < Analyzers.Length; index++)
			{
				builder.Append(string.Join("", queues[index]));
			}
			builder.AppendLine("}");
			return builder.ToString();
		}
开发者ID:tianzhiyuan,项目名称:agile,代码行数:57,代码来源:NavigationAnalyzer.cs

示例4: AppendLineFormat

 public void AppendLineFormat()
 {
     StringBuilder Builder=new StringBuilder();
     Builder.AppendLineFormat("This is test {0}",1);
     Assert.Equal("This is test 1" + System.Environment.NewLine, Builder.ToString());
     Builder.Clear();
     Builder.AppendLineFormat("Test {0}", 2)
         .AppendLineFormat("And {0}", 3);
     Assert.Equal("Test 2" + System.Environment.NewLine + "And 3" + System.Environment.NewLine, Builder.ToString());
 }
开发者ID:Adilson,项目名称:Craig-s-Utility-Library,代码行数:10,代码来源:StringExtensions.cs

示例5: GenerateQueryStatement

		public string GenerateQueryStatement(Type queryType)
		{
			if (!TypeUtils.IsBaseEntityQuery(queryType))
			{
				throw new ArgumentException("not a valid query type", "queryType");
			}
			Type baseType = queryType.BaseType;
			while (!baseType.IsGenericType)
			{
				baseType = baseType.BaseType;
			}
			var modelType = baseType.GetGenericArguments()[0];
			if (!TypeUtils.IsBaseEntity(modelType))
			{
				throw new ArgumentException("generic type is not a valid model type", "queryType");
			}

			var queryProperties = queryType.GetProperties();
			var modelProperties = modelType.GetProperties();
			var builder = new StringBuilder();
			builder.AppendLine("#region override DoQuery <auto-generated-code>");
			builder.AppendLineFormat("public override IQueryable<{0}> {2}(IQueryable<{0}> {1})", modelType.Name, SourceParamName, QueryFuncName);
			builder.AppendLine("{");
			foreach (var queryProperty in queryProperties)
			{
				var context = new AnalyzeContext()
					{
						QueryProperty = queryProperty,
						ModelType = modelType,
						SourceParamName = SourceParamName,
						QueryParamName = "this"
					};
				for (var index = 0; index < Analyzers.Length; index++)
				{
					var analyzer = Analyzers[index];
					var modelProperty = analyzer.FindAttachedModelProperty(queryProperty, modelProperties);
					if (modelProperty == null) continue;
					context.ModelProperty = modelProperty;
					var statment = analyzer.ParseStatement(context);
					queues[index].Add(statment);
				}
			}
			for (var index = 0; index < Analyzers.Length; index++)
			{
				builder.Append(string.Join("", queues[index]));
			}
			builder.Append(new PaginationAnalyzer().ParseStatement(modelProperties, SourceParamName));
			builder.AppendLineFormat("return {0};", SourceParamName);
			builder.AppendLine("}");
			builder.AppendLine("#endregion");
			return builder.ToString();
		}
开发者ID:tianzhiyuan,项目名称:agile,代码行数:52,代码来源:QueryObjectParser.cs

示例6: DumpGraph

        public static void DumpGraph(string workingDirectory, Action<string> writer = null, int? maxCommits = null)
        {
            var output = new StringBuilder();

            try
            {
                ProcessHelper.Run(
                    o => output.AppendLine(o),
                    e => output.AppendLineFormat("ERROR: {0}", e),
                    null,
                    "git",
                    @"log --graph --format=""%h %cr %d"" --decorate --date=relative --all --remotes=*" + (maxCommits != null ? string.Format(" -n {0}", maxCommits) : null),
                    //@"log --graph --abbrev-commit --decorate --date=relative --all --remotes=*",
                    workingDirectory);
            }
            catch (FileNotFoundException exception)
            {
                if (exception.FileName != "git")
                {
                    throw;
                }

                output.AppendLine("Could not execute 'git log' due to the following error:");
                output.AppendLine(exception.ToString());
            }

            if (writer != null) writer(output.ToString());
            else Trace.Write(output.ToString());
        }
开发者ID:nick4eva,项目名称:GitVersion,代码行数:29,代码来源:LibGitExtensions.cs

示例7: DumpGraph

    public static void DumpGraph(this IRepository repository)
    {
        var output = new StringBuilder();

        try
        {
            ProcessHelper.Run(
                o => output.AppendLine(o),
                e => output.AppendLineFormat("ERROR: {0}", e),
                null,
                "git",
                @"log --graph --abbrev-commit --decorate --date=relative --all --remotes=*",
                repository.Info.Path);
        }
        catch (FileNotFoundException exception)
        {
            if (exception.FileName != "git")
                throw;

            output.AppendLine("Could not execute 'git log' due to the following error:");
            output.AppendLine(exception.ToString());
        }

        Trace.Write(output.ToString());
    }
开发者ID:nakioman,项目名称:GitVersion,代码行数:25,代码来源:GitTestExtensions.cs

示例8: ToString

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.AppendLineFormat("Id: {0}", Id);
            sb.AppendLineFormat("FirstName: {0}", FirstName);
            sb.AppendLineFormat("LastName: {0}", LastName);
            sb.AppendLineFormat("EmailAddress: {0}", EmailAddress);
            foreach (var language in Languages)
            {
                sb.AppendLineFormat("Language: {0}", language.LanguageCode);
            }

            sb.AppendLineFormat("Registration: {0}-{1}-{2}", RegistrationDate.Year, RegistrationNumber,
                RegistrationSuffix);

            return sb.ToString();
        }
开发者ID:Jalalhejazi,项目名称:LuceneWrapper,代码行数:17,代码来源:Person.cs

示例9: AppendLineFormat

        public void AppendLineFormat()
        {
            // Type
            var @this = new StringBuilder();

            // Exemples
            @this.AppendLineFormat("{0}{1}", "Fizz", "Buzz"); // return "FizzBuzz";

            // Unit Test
            Assert.AreEqual("FizzBuzz" + Environment.NewLine, @this.ToString());
        }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:11,代码来源:StringBuilder.AppendLineFormat.cs

示例10: ParseStatement

		public string ParseStatement(AnalyzeContext context)
		{
			var queryPropertyName = context.QueryProperty.Name;
			var modelPropertyName = context.ModelProperty.Name;
			var navigation = new List<string>(context.Navigations) { modelPropertyName };
			var builder = new StringBuilder();
			builder.AppendLineFormat("if({0} != null)", context.QueryParamName + "." + queryPropertyName)
			       .AppendLine("{")
				   .AppendLineFormat("{0}={0}.Where(o=>o.{1}.Contains({2}));", context.SourceParamName, string.Join(".", navigation), context.QueryParamName + "." + queryPropertyName)
			       .AppendLine("}");
			return builder.ToString();
		}
开发者ID:tianzhiyuan,项目名称:agile,代码行数:12,代码来源:StringContainsAnalyzer.cs

示例11: ToConfigurationFile

        public virtual string ToConfigurationFile()
        {
            StringBuilder sb = new StringBuilder();

            Type type = this.GetType();
            var props = type.GetProperties();
            foreach (var prop in props)
            {
                sb.AppendLineFormat("{0}={1}", prop.Name, prop.GetValue(this, null));
            }

            return sb.ToString();
        }
开发者ID:drorgl,项目名称:MSDNSWebAdmin,代码行数:13,代码来源:Backupable.cs

示例12: AppendLineFormatTestCase1

        public void AppendLineFormatTestCase1()
        {
            var value0 = RandomValueEx.GetRandomString();

            var sb = new StringBuilder();
            sb.AppendLine( "Line 1" );
            sb.AppendLineFormat( "Test: {0}", value0 );
            sb.AppendLine( "Line 3" );

            var expected = "Line 1\r\nTest: {0}\r\nLine 3\r\n".F( value0 );
            var actual = sb.ToString();
            Assert.AreEqual( expected, actual );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:13,代码来源:StringBuilder.AppendLineFormat.Test.cs

示例13: WriteOutputHeader

        /// <summary>
        /// Writes the output header.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="programName">Name of the program.</param>
        public void WriteOutputHeader(TextWriter writer, string programName)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(programName);
            sb.AppendLine();
            sb.AppendLineFormat("Today's Date: {0}", context.TodaysDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Start Date: {0}", context.StartDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Target End Date: {0}", context.TargetEndDate.ToString(Constants.DATE_FORMAT));
            sb.AppendLineFormat("Balance: {0}", context.Balance.ToString("c"));
            sb.AppendLineFormat("Interest Rate: {0}%", context.InterestRate.ToString("n2"));
            sb.AppendLineFormat("Min. Repayment Amount: {0}", context.MinRepaymentAmount.ToString("c"));
            sb.AppendLineFormat("Min. Repayment Day: {0}", context.MinRepaymentDay);
            sb.AppendLineFormat("Extra Repayment Amount: {0}", context.ExtraRepaymentAmount.ToString("c"));
            sb.AppendLineFormat("Extra Repayment Day: {0}", context.ExtraRepaymentDay);
            sb.AppendLine();
            sb.AppendLine();
            writer.Write(sb.ToString());
        }
开发者ID:retroburst,项目名称:Kata,代码行数:24,代码来源:LoanCalculationOutputStreamWriter.cs

示例14: DumpGraph

    public static void DumpGraph(this IRepository repository)
    {
        var output = new StringBuilder();

        ProcessHelper.Run(
            o => output.AppendLine(o),
            e => output.AppendLineFormat("ERROR: {0}", e),
            null,
            "git",
            @"log --graph --abbrev-commit --decorate --date=relative --all",
            repository.Info.Path);

        Trace.Write(output.ToString());
    }
开发者ID:Wikell,项目名称:GitVersion,代码行数:14,代码来源:GitTestExtensions.cs

示例15: Generate

 /// <summary>
 /// Generates the specified assemblies using.
 /// </summary>
 /// <param name="assembliesUsing">The assemblies using.</param>
 /// <param name="aspects">The aspects.</param>
 /// <returns></returns>
 public string Generate(List<Assembly> assembliesUsing, IEnumerable<IAspect> aspects)
 {
     var Builder = new StringBuilder();
     Builder.AppendLineFormat(@"
         public {0}()
             {1}
         {{
             {2}
         }}",
         DeclaringType.Name + "Derived",
         DeclaringType.IsInterface ? "" : ":base()",
         aspects.ToString(x => x.SetupDefaultConstructor(DeclaringType)));
     return Builder.ToString();
 }
开发者ID:JaCraig,项目名称:Craig-s-Utility-Library,代码行数:20,代码来源:ConstructorGenerator.cs


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