本文整理汇总了C#中StringFormatter.Append方法的典型用法代码示例。如果您正苦于以下问题:C# StringFormatter.Append方法的具体用法?C# StringFormatter.Append怎么用?C# StringFormatter.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringFormatter
的用法示例。
在下文中一共展示了StringFormatter.Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomTypeToString
public void CustomTypeToString()
{
var sb = new StringFormatter();
sb.Append(new Age(56));
sb.Append(new Age(14, inMonths: true));
Assert.Equal(sb.ToString(), "56y14m");
}
示例2: FormatGuid
public void FormatGuid()
{
var guid = Guid.NewGuid();
var sb = new StringFormatter();
sb.Append(guid);
Assert.Equal(guid.ToString(), sb.ToString());
sb.Clear();
sb.Append(guid, 'D');
Assert.Equal(guid.ToString("D"), sb.ToString());
sb.Clear();
sb.Append(guid, 'N');
Assert.Equal(guid.ToString("N"), sb.ToString());
sb.Clear();
sb.Append(guid, 'B');
Assert.Equal(guid.ToString("B"), sb.ToString());
sb.Clear();
sb.Append(guid, 'P');
Assert.Equal(guid.ToString("P"), sb.ToString());
sb.Clear();
}
示例3: BasicStringFormatter
public void BasicStringFormatter()
{
var sb = new StringFormatter();
sb.Append("hi");
sb.Append(1);
sb.Append("hello");
sb.Append((sbyte)-20);
Assert.Equal("hi1hello-20", sb.ToString());
}
示例4: CustomCulture
public void CustomCulture()
{
var sb = new StringFormatter(ArrayPool<byte>.Shared);
sb.FormattingData = FormattingDataProvider.CreateFormattingData("pl-PL");
sb.Append(-10000, Format.Parse('N'));
Assert.Equal("-10\u00A0000,00", sb.ToString()); // \u00A0 is a space group separator
}
示例5: CustomCulture
public void CustomCulture()
{
var sb = new StringFormatter();
sb.Encoding = Culture5;
sb.Append(-1234567890);
Assert.Equal("_?BBBBBCCCCCDDDDDEEEEEFFFFFGGGGGHHHHHIIIIIJJJJJAAAAA", sb.ToString());
}
示例6: CustomCulture
public void CustomCulture()
{
var sb = new StringFormatter();
sb.Encoding = EncodingProvider.CreateEncoding("pl-PL");
sb.Append(-10000, TextFormat.Parse('N'));
Assert.Equal("-10\u00A0000,00", sb.ToString()); // \u00A0 is a space group separator
}
示例7: CustomCulture
public void CustomCulture()
{
var pool = new ManagedBufferPool<byte>(1024);
var sb = new StringFormatter(pool);
sb.FormattingData = FormattingDataProvider.CreateFormattingData("pl-PL");
sb.Append(-10000, Format.Parse('N'));
Assert.Equal("-10\u00A0000,00", sb.ToString()); // \u00A0 is a space group separator
}
示例8: FormatDateTimeOffsetR
public void FormatDateTimeOffsetR()
{
var time = DateTimeOffset.UtcNow;
var sb = new StringFormatter(pool);
sb.Append(time, 'R');
Assert.Equal(time.ToString("R"), sb.ToString());
sb.Clear();
}
示例9: FormatDateTimeO
public void FormatDateTimeO()
{
var time = DateTime.UtcNow;
var sb = new StringFormatter();
sb.Append(time, 'O');
Assert.Equal(time.ToString("O", CultureInfo.InvariantCulture), sb.ToString());
sb.Clear();
}
示例10: CheckTimeSpan
public void CheckTimeSpan(TimeSpan value, string format)
{
var parsed = Format.Parse(format);
var formatter = new StringFormatter(pool);
formatter.Append(value, parsed);
var result = formatter.ToString();
var clrResult = value.ToString(format, CultureInfo.InvariantCulture);
Assert.Equal(clrResult, result);
}
示例11: FormatTimeSpan
public void FormatTimeSpan()
{
var time = new TimeSpan(1000, 23, 40, 30, 12345);
var sb = new StringFormatter();
sb.Append(time);
Assert.Equal(time.ToString("", CultureInfo.InvariantCulture), sb.ToString());
sb.Clear();
}
示例12: FormatDateTimeG
public void FormatDateTimeG()
{
var time = DateTime.UtcNow;
var sb = new StringFormatter();
sb.Append(time, 'G');
Assert.Equal(time.ToString("G"), sb.ToString());
sb.Clear();
}
示例13: CheckByte
private void CheckByte(byte value, string format, string expected)
{
var formatter = new StringFormatter(pool);
var parsed = Format.Parse(format);
formatter.Clear();
formatter.Append(value, parsed);
var result = formatter.ToString();
Assert.Equal(expected, result);
var clrResult = value.ToString(format, CultureInfo.InvariantCulture);
Assert.Equal(clrResult, result);
}
示例14: FloatFormatting
public void FloatFormatting()
{
var sb = new StringFormatter(pool);
sb.Append(Double.NaN);
var result = sb.ToString();
Assert.Equal("NaN", result);
sb.Clear();
sb.Append(Double.PositiveInfinity);
result = sb.ToString();
Assert.Equal("Infinity", result);
sb.Clear();
sb.Append(Double.NegativeInfinity);
result = sb.ToString();
Assert.Equal("-Infinity", result);
sb.Clear();
sb.Append(1.2);
result = sb.ToString();
Assert.Equal("1.2", result);
}
示例15: InvariantFormatIntHex
private void InvariantFormatIntHex()
{
timer.Restart();
for (int itteration = 0; itteration < itterationsInvariant; itteration++)
{
StringFormatter sb = new StringFormatter(numbersToWrite, pool);
for (int i = 0; i < numbersToWrite; i++)
{
sb.Append(((int)(i % 10)), Format.Parsed.HexUppercase);
}
var text = sb.ToString();
if (text.Length != numbersToWrite)
{
throw new Exception("test failed");
}
}
PrintTime();
}