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


C# StringBuilder.TrimEnd方法代码示例

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


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

示例1: TriemEndTest

 public void TriemEndTest()
 {
     StringBuilder sb;
     sb = new StringBuilder("asdfgef");
     Assert.Equal(sb.TrimEnd('a').ToString(), "asdfgef");
     Assert.Equal(sb.TrimEnd('f').ToString(), "asdfge");
     sb.Append("   ");
     Assert.Equal(sb.TrimEnd().ToString(), "asdfge");
     Assert.Equal(sb.TrimEnd(new[] { 'g', 'e' }).ToString(), "asdf");
     Assert.Equal(sb.TrimEnd("asdf").ToString(), string.Empty);
 }
开发者ID:BiaoLiu,项目名称:osharp,代码行数:11,代码来源:StringBuilderExtensionsTest.cs

示例2: can_trim_end_of_stringbuffer

 public void can_trim_end_of_stringbuffer()
 {
     var sb1 = new StringBuilder("foo1234   \r\n");
     var sb2 = new StringBuilder("foo1234");
     Assert.AreEqual("foo1234", sb1.TrimEnd().ToString());
     Assert.AreEqual("foo1234", sb2.TrimEnd().ToString());
 }
开发者ID:geofflane,项目名称:zorched-migrations,代码行数:7,代码来源:StringExtensionTests.cs

示例3: can_trim_character_end_of_stringbuffer

 public void can_trim_character_end_of_stringbuffer()
 {
     var sb1 = new StringBuilder("foo1234");
     var sb2 = new StringBuilder("foo1233");
     Assert.AreEqual("foo123", sb1.TrimEnd('4').ToString());
     Assert.AreEqual("foo1233", sb2.TrimEnd('4').ToString());
 }
开发者ID:geofflane,项目名称:zorched-migrations,代码行数:7,代码来源:StringExtensionTests.cs

示例4: ViewSql

        public string ViewSql(Process process) {

            const string fieldSpacer = ",\r\n    ";
            var builder = new StringBuilder();
            var master = process.MasterEntity;
            var l = process.OutputConnection.L;
            var r = process.OutputConnection.R;

            builder.AppendLine("SELECT");
            builder.Append("    ");
            builder.Append(new FieldSqlWriter(master.OutputFields()).Alias(l, r).Prepend("m.").Write(fieldSpacer));

            foreach (var rel in process.Relationships) {
                var joinFields = rel.Fields();
                foreach (var field in rel.RightEntity.OutputFields()) {
                    if (!joinFields.HaveField(field.Alias)) {
                        builder.Append(fieldSpacer);
                        builder.Append(new FieldSqlWriter(new Fields(field)).Alias(l, r).Prepend("r" + rel.RightEntity.Index + ".").Write(fieldSpacer));
                    }
                }
            }

            builder.AppendLine();
            builder.Append("FROM ");
            builder.Append(l);
            builder.Append(master.OutputName());
            builder.Append(r);
            builder.Append(" m");

            foreach (var rel in process.Relationships) {
                builder.AppendLine();
                builder.Append("LEFT OUTER JOIN ");
                if (rel.RightEntity.IsMaster()) {
                    builder.Append("m");
                } else {
                    builder.Append(l);
                    builder.Append(rel.RightEntity.OutputName());
                    builder.Append(r);
                }
                builder.Append(" ");
                builder.Append("r");
                builder.Append(rel.RightEntity.Index);
                builder.Append(" ON (");
                foreach (var j in rel.Join) {
                    if (rel.LeftEntity.IsMaster()) {
                        builder.Append("m");
                    } else {
                        builder.Append("r");
                        builder.Append(rel.LeftEntity.Index);
                    }
                    builder.Append(".");
                    builder.Append(l);
                    builder.Append(j.LeftField.Alias);
                    builder.Append(r);
                    builder.Append(" = ");
                    builder.Append("r");
                    builder.Append(rel.RightEntity.Index);
                    builder.Append(".");
                    builder.Append(l);
                    builder.Append(j.RightField.Alias);
                    builder.Append(r);
                    builder.Append(" AND ");
                }
                builder.TrimEnd(" AND ");
                builder.Append(")");
            }

            builder.Append(";");
            return builder.ToString();

        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:71,代码来源:SqlServerViewWirter.cs

示例5: CreateSql

        public string CreateSql(Process process) {
            var builder = new StringBuilder();
            builder.AppendFormat("CREATE VIEW {0} AS\r\n", process.OutputConnection.Enclose(process.Star));
            builder.AppendFormat("SELECT\r\n    d.TflKey,\r\n    d.TflBatchId,\r\n    b.TflUpdate,\r\n");

            var l = process.OutputConnection.L;
            var r = process.OutputConnection.R;

            var typedFields = new StarFields(process).TypedFields();
            builder.AppendLine(string.Concat(new FieldSqlWriter(typedFields[StarFieldType.Master]).Alias(l, r).PrependEntityOutput(process.OutputConnection, "d").Prepend("    ").Write(",\r\n"), ","));

            if (typedFields[StarFieldType.Foreign].Any())
                builder.AppendLine(string.Concat(new FieldSqlWriter(typedFields[StarFieldType.Foreign]).Alias(l, r).PrependEntityOutput(process.OutputConnection, "d").IsNull().ToAlias(l, r).Prepend("    ").Write(",\r\n"), ","));

            if (typedFields[StarFieldType.Other].Any())
                builder.AppendLine(string.Concat(new FieldSqlWriter(typedFields[StarFieldType.Other]).Alias(l, r).PrependEntityOutput(process.OutputConnection).IsNull().ToAlias(l, r).Prepend("    ").Write(",\r\n"), ","));

            builder.TrimEnd("\r\n,");
            builder.AppendLine();
            builder.AppendFormat("FROM {0} d\r\n", process.OutputConnection.Enclose(process.MasterEntity.OutputName()));
            builder.AppendFormat("INNER JOIN TflBatch b ON (d.TflBatchId = b.TflBatchId AND b.ProcessName = '{0}')\r\n", process.Name);

            foreach (var entity in process.Entities.Where(e => !e.IsMaster())) {
                builder.AppendFormat("LEFT OUTER JOIN {0} ON (", entity.OutputName());

                foreach (var join in entity.RelationshipToMaster.First().Join.ToArray()) {
                    builder.AppendFormat(
                        "d.{0} = {1}.{2} AND ",
                        process.OutputConnection.Enclose(join.LeftField.Alias),
                        entity.OutputName(),
                        process.OutputConnection.Enclose(join.RightField.Alias));
                }

                builder.TrimEnd(" AND ");
                builder.AppendLine(")");
            }

            builder.Append(";");
            return builder.ToString();
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:40,代码来源:SqlServerStarViewWriter.cs


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