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


C# StringBuilder.Trim方法代码示例

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


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

示例1: DoToWhereStatement

		/// <summary>
		/// Constructs a WHERE statements on this column for the given <paramref name="values"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="commandContext">The <see cref="QueryCommandContext"/>.</param>
		/// <param name="pair">The <see cref="TableColumnPair"/>.</param>
		/// <param name="values">The values on which to construct the where statement.</param>
		protected override void DoToWhereStatement(IMansionContext context, QueryCommandContext commandContext, TableColumnPair pair, IList<object> values)
		{
			// add the table to the query
			commandContext.QueryBuilder.AddTable(context, pair.Table, commandContext.Command);

			// check for single or multiple values
			if (values.Count == 1)
				commandContext.QueryBuilder.AppendWhere(" [{0}].[{1}] = @{2}", pair.Table.Name, pair.Column.ColumnName, commandContext.Command.AddParameter(values[0]));
			else
			{
				// start the clause
				var buffer = new StringBuilder();
				buffer.AppendFormat("[{0}].[{1}] IN (", pair.Table.Name, pair.Column.ColumnName);

				// loop through all the values
				foreach (var value in values)
					buffer.AppendFormat("@{0},", commandContext.Command.AddParameter(value));

				// finish the clause
				commandContext.QueryBuilder.AppendWhere("{0})", buffer.Trim());
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:29,代码来源:IdentityColumn.cs

示例2: Execute

        public override IEnumerable<Row> Execute(IEnumerable<Row> rows) {

            var line = 1;
            var isBinary = _fileInfo.Extension == ".xls";
            using (var fileStream = File.Open(_fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {

                using (var reader = isBinary ? ExcelReaderFactory.CreateBinaryReader(fileStream) : ExcelReaderFactory.CreateOpenXmlReader(fileStream)) {

                    if (reader == null) {
                        yield break;
                    }

                    var emptyBuilder = new StringBuilder();

                    while (reader.Read()) {
                        line++;

                        if (line > _start) {
                            if (_end == 0 || line <= _end) {
                                var row = new Row();
                                row["TflFileName"] = _fileInfo.FullName;
                                emptyBuilder.Clear();
                                foreach (var field in _fields) {
                                    var value = reader.GetValue(field.Index);
                                    row[field.Alias] = value;
                                    emptyBuilder.Append(value);
                                }
                                emptyBuilder.Trim(" ");
                                if (!emptyBuilder.ToString().Equals(string.Empty)) {
                                    yield return row;
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:37,代码来源:FileExcelExtract.cs

示例3: TrimTest

 public void TrimTest()
 {
     StringBuilder sb = null;
     sb = new StringBuilder("   asd sdf  ");
     Assert.Equal(sb.Trim().ToString(), "asd sdf");
 }
开发者ID:BiaoLiu,项目名称:osharp,代码行数:6,代码来源:StringBuilderExtensionsTest.cs

示例4: DoToSyncStatement

		/// <summary>
		/// Generates an table sync statement for this table.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="bulkContext"></param>
		/// <param name="records"></param>
		protected override void DoToSyncStatement(IMansionContext context, BulkOperationContext bulkContext, List<Record> records)
		{
			// start by clearing the table
			bulkContext.Add(command =>
			                {
			                	command.CommandType = CommandType.Text;
			                	command.CommandText = string.Format("TRUNCATE TABLE [{0}]", Name);
			                });

			// loop through all the properties
			foreach (var record in records)
			{
				// prepare the query
				var columnText = new StringBuilder();
				var valueText = new StringBuilder();

				// finish the query
				var currentRecord = record;
				bulkContext.Add(command =>
				                {
				                	// loop through all the columns
				                	foreach (var column in Columns)
				                		column.ToSyncStatement(context, command, currentRecord, columnText, valueText);

				                	// construct the command
				                	command.CommandType = CommandType.Text;
				                	command.CommandText = string.Format("INSERT INTO [{0}] ({1}) VALUES ({2});", Name, columnText.Trim(), valueText.Trim());
				                });
			}
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:36,代码来源:TypeTable.cs

示例5: MinifyQuery

        private static string MinifyQuery(string query)
        {
            // Removes all SQL comments. Multiline excludes '/n' from '.' matches.
            query = Regex.Replace(query, @"--.*", string.Empty, RegexOptions.Multiline | RegexOptions.Compiled);

            // Removes all multiple blanks.
            query = Regex.Replace(query, @"\s+", " ", RegexOptions.Compiled);

            // Removes query placeholders.
            query = new StringBuilder(query)
                .Replace("{CacheVariablesPartition}", "'KVLite.CacheVariables'")
                .Replace("{InsertionCountVariable}", "'insertion_count'")
                .Replace("{CacheVariablesIntervalInSeconds}", "3600000") // 1000 hours
                .ToString();

            // Removes initial and ending blanks.
            return query.Trim();
        }
开发者ID:pomma89,项目名称:KVLite,代码行数:18,代码来源:SQLiteQueries.cs


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