本文整理汇总了C#中StringBuilder.RemoveLast方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuilder.RemoveLast方法的具体用法?C# StringBuilder.RemoveLast怎么用?C# StringBuilder.RemoveLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder.RemoveLast方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveLastEmptyInstance
public void RemoveLastEmptyInstance()
{
StringBuilder sb = new StringBuilder();
string expected = "";
sb.RemoveLast("!");
Assert.AreEqual(expected, sb.ToString());
}
示例2: RemoveLastExactMatch
public void RemoveLastExactMatch()
{
StringBuilder sb = new StringBuilder();
sb.Append("!");
string expected = "";
sb.RemoveLast("!");
Assert.AreEqual(expected, sb.ToString());
}
示例3: RemoveLast
public void RemoveLast()
{
StringBuilder sb = new StringBuilder();
sb.Append("Something awesome!!");
string expected = "Something awesome!";
sb.RemoveLast("!");
Assert.AreEqual(expected, sb.ToString());
}
示例4: Print
static object Print(object x)
{
var ie = x as System.Collections.IEnumerable;
if (ie != null)
{
var sb = new StringBuilder("[");
foreach (var y in ie) sb.AppendFormat("{0}, ", Print(y));
return sb.RemoveLast(2).Append("]").ToString();
}
return x;
}
示例5: AddIndexes
private void AddIndexes(List<IndexDefinition> indexes)
{
var sb=new StringBuilder();
indexes.ForEach(idx =>
{
sb.Clear();
sb.Append("create ");
if (idx.IsUnique) sb.Append("unique ");
sb.Append("index ");
sb.Append(idx.Name ?? "ix_" + _data.TableName.DDLUsableString + "_" + StringUtils.CreateRandomString(7));
sb.Append($" on {_tableName}(");
idx.Columns.ForEach(n =>
{
sb.Append(n + ",");
});
sb.RemoveLast().Append(")");
sb.AppendLine(";");
_sb.Append(_provider.FormatIndexOptions(sb.ToString(), idx.Options));
});
}
示例6: FactMethodName
public void FactMethodName()
{
Expression<Func<Test, bool>> data = t => new[] {1, 2}.Contains(t.Id);
var meth = ObjectExtend.CastAs<MethodCallExpression>(data.Body);
Assert.Equal("Contains",meth.Method.Name);
var param = ObjectExtend.CastAs<MemberExpression>(meth.Arguments[1]);
Assert.True(param.BelongsToParameter());
var sb = new StringBuilder();
sb.Append(param.Member.Name).Append(" in (");
var list = ObjectExtend.CastAs<IEnumerable>(meth.Arguments[0].GetValue());
var en=list.GetEnumerator();
while (en.MoveNext())
{
sb.Append(en.Current).Append(",");
}
sb.RemoveLast();
sb.Append(")");
Write(sb.ToString());
}
示例7: AddConstraints
private void AddConstraints(PKData primaryKey)
{
if (primaryKey == null) return;
var sb=new StringBuilder();
var name = primaryKey.Name.IsNullOrEmpty()?"pk_" + _data.TableName.DDLUsableString:primaryKey.Name;
sb.Append($"constraint {name} primary key (");
primaryKey.Columns.ForEach(c =>
{
sb.Append(_provider.EscapeIdentifier(c) + ",");
});
sb.RemoveLast();
sb.AppendLine(")");
_sb.AppendLine(","+_provider.FormatIndexOptions(sb.ToString(), primaryKey.Options));
}
示例8: GetColumnsSql
public string GetColumnsSql(params Expression[] columns)
{
var sb=new StringBuilder();
columns.ForEach(d=>sb.Append($"{_results["col"].Dequeue()},"));
return sb.RemoveLast().ToString();
}
示例9: BuildArguments
string BuildArguments(string[] targets)
{
var sb = new StringBuilder();
sb.Append(_projFile);
sb.AppendFormat(" /m:{0}",_count<=1?1:_count);
sb.Append(" /v:" + Parse(_verbosity));
if (Properties != null)
{
sb.Append(" /p:");
foreach (var name in Properties.AllKeys)
{
sb.AppendFormat("{0}={1};", name, Properties[name]);
}
sb.RemoveLast();
}
if (targets.Length > 0)
{
sb.Append(" /t:");
foreach (var t in targets)
{
sb.Append(t + ";");
}
sb.RemoveLast();
}
sb.Append(" /clp:ErrorsOnly;PerformanceSummary");
return sb.ToString();
}
示例10: WriteColumnsNames
public static void WriteColumnsNames(ICollection<string> columns, StringBuilder builder,
Func<string, string> formatter)
{
columns.MustNotBeNull();
formatter.MustNotBeNull();
foreach (var column in columns)
{
builder.Append(formatter(column.Trim())).Append(",");
}
builder.RemoveLast();
}
示例11: FromXmlTransformations
//.........这里部分代码省略.........
GroupCondition = conditionSymbol
};
var cdaTag = await CreateCdaTags(rule);
rules.Add(rule);
cdaTags.Add(cdaTag);
if (entityCodeWithPrefix)
{
entityCode = AddPrefixToEntityCode(rule);
}
cdaBuilderXPath.AppendFormat(XPathEntityPrefix, entityCode);
cdaBuilderXQuery.AppendFormat(XQueryEntityPrefix, entityCode);
tryGet = Operators.ListKeyValue.TryGetValue(operatorSymbol.ToLower(), out operatorObj);
if (tryGet)
{
cdaBuilderXPath.AppendFormat(@" {0}", string.Format(operatorObj.XPathValue, value));
cdaBuilderXQuery.AppendFormat(@" {0}", string.Format(operatorObj.XPathValue, value));
}
tryGet = Conditions.ListKeyValue.TryGetValue(conditionSymbol.ToLower(), out conditionObj);
if (tryGet)
{
cdaBuilderXPath.AppendFormat(@" {0} ", conditionObj.Value);
cdaBuilderXQuery.AppendFormat(@" {0} ", conditionObj.Value);
}
}
cdaBuilderXPath.RemoveLast($" {conditionObj.Value} ");
cdaBuilderXQuery.RemoveLast($" {conditionObj.Value} ");
cdaBuilderXPath.AppendFormat(@"{0}", closeGroupChar);
cdaBuilderXQuery.AppendFormat(@"{0}", closeGroupChar);
tryGet = Conditions.ListKeyValue.TryGetValue(conditionSymbol.ToLower(), out conditionObj);
if (tryGet)
{
cdaBuilderXPath.AppendFormat(@" {0} ", conditionObj.Value);
cdaBuilderXQuery.AppendFormat(@" {0} ", conditionObj.Value);
}
}
cdaBuilderXPath.RemoveLast($" {conditionObj.Value} ");
cdaBuilderXQuery.RemoveLast($" {conditionObj.Value} ");
var internalCode = await CreateCdaInternalCode(rules);
if (otherQueries?.Count > 0)
{
QueryTransformations.Element("QUERIES").Add(otherQueries);
}
var cdaBuilderXPathEscaped = cdaBuilderXPath.ToString().EscapeString();
var cdaBuilderXQueryEscaped = cdaBuilderXPath.ToString().EscapeString();
returnTypes.ForEach(type =>
{
var queryElement = new XElement("QUERY", new XAttribute("NAME", queryName));
switch (type)
示例12: FromJsonToTagsSqlQuery
/// <summary>
///
/// </summary>
/// <param name="jsonCda"></param>
/// <param name="tagTextColumnName"></param>
/// <param name="entityCodeColumnName"></param>
/// <returns></returns>
public static async Task<string> FromJsonToTagsSqlQuery(string jsonCda, string tagTextColumnName, string entityCodeColumnName)
{
Debug.Assert(!string.IsNullOrWhiteSpace(jsonCda), "jsonCda is null or empty");
var fakeCdaMasterObj = new CdaMasterDto()
{
GlobalId = new Guid(),
Id = -1,
Version = 1,
Name = string.Empty,
Active = true,
Cancelled = false,
Code = string.Empty,
CreationTime = DateTime.UtcNow,
UpdatedTime = DateTime.UtcNow,
Description = string.Empty,
Domain = string.Empty,
IdPlantCreator = 1,
XsdVersion = string.Empty
};
XNode cdaXml = await FromJsonToXml(fakeCdaMasterObj, jsonCda);
XElement conditionsRoot = ((XElement)cdaXml).FirstNode as XElement;
var queryBuilder = new StringBuilder();
char openGroupChar = '(';
char closeGroupChar = ')';
var conditionSymbol = string.Empty;
foreach (var group in conditionsRoot.Descendants("GROUP"))
{
conditionSymbol = group.Attribute("CONDITION").Value;
queryBuilder.AppendFormat(@"{0}", openGroupChar);
foreach (var ruleElement in group.Elements("RULE"))
{
var entityCode = ruleElement.Attribute("ENTITYCODE").Value;
var entityType = ruleElement.Attribute("ENTITYTYPE").Value;
var operatorSymbol = ruleElement.Attribute("OPERATOR").Value;
var value = ruleElement.Attribute("VALUE").Value;
if (!string.IsNullOrEmpty(value))
{
queryBuilder.AppendFormat(@"{0} = ""{1} {2} {3}""", tagTextColumnName, entityCode, operatorSymbol.ToLower(), value);
}
else
{
queryBuilder.AppendFormat(@"{0} = ""{1}""", entityCodeColumnName, entityCode);
}
queryBuilder.AppendFormat(@" {0} ", conditionSymbol);
}
queryBuilder.RemoveLast($" {conditionSymbol} ");
queryBuilder.AppendFormat(@"{0}", closeGroupChar);
queryBuilder.AppendFormat(@" {0} ", conditionSymbol);
}
queryBuilder.RemoveLast($" {conditionSymbol} ");
return await Task.FromResult(queryBuilder.ToString());
}