本文整理汇总了C#中ObjectDisplayOptions.IncludesOption方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectDisplayOptions.IncludesOption方法的具体用法?C# ObjectDisplayOptions.IncludesOption怎么用?C# ObjectDisplayOptions.IncludesOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectDisplayOptions
的用法示例。
在下文中一共展示了ObjectDisplayOptions.IncludesOption方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatLiteral
internal static string FormatLiteral(short value, ObjectDisplayOptions options)
{
if (options.IncludesOption(ObjectDisplayOptions.UseHexadecimalNumbers))
{
// Special Case: for sbyte and short, specifically, negatives are shown
// with extra precision.
return "0x" + (value >= 0 ? value.ToString("x4") : ((int)value).ToString("x8"));
}
else
{
return value.ToString(CultureInfo.InvariantCulture);
}
}
示例2: FormatLiteral
internal static string FormatLiteral(uint value, ObjectDisplayOptions options, CultureInfo cultureInfo = null)
{
var pooledBuilder = PooledStringBuilder.GetInstance();
var sb = pooledBuilder.Builder;
if (options.IncludesOption(ObjectDisplayOptions.UseHexadecimalNumbers))
{
sb.Append("0x");
sb.Append(value.ToString("x8"));
}
else
{
sb.Append(value.ToString(GetFormatCulture(cultureInfo)));
}
if (options.IncludesOption(ObjectDisplayOptions.IncludeTypeSuffix))
{
sb.Append('U');
}
return pooledBuilder.ToStringAndFree();
}
示例3: FormatString
internal override string FormatString(string str, ObjectDisplayOptions options)
{
return ObjectDisplay.FormatString(str, useQuotes: options.IncludesOption(ObjectDisplayOptions.UseQuotes));
}
示例4: FormatLiteral
/// <summary>
/// Returns a C# string literal with the given value.
/// </summary>
/// <param name="value">The value that the resulting string literal should have.</param>
/// <param name="options">Options used to customize formatting of an object value.</param>
/// <returns>A string literal with the given value.</returns>
/// <remarks>
/// Escapes non-printable characters.
/// </remarks>
public static string FormatLiteral(string value, ObjectDisplayOptions options)
{
ValidateOptions(options);
if (value == null)
{
throw new ArgumentNullException("value");
}
return FormatString(value, options.IncludesOption(ObjectDisplayOptions.UseQuotes) ? '"' : '\0', escapeNonPrintable: true);
}
示例5: FormatLiteral
internal static string FormatLiteral(float value, ObjectDisplayOptions options)
{
ValidateOptions(options);
var result = value.ToString("R", CultureInfo.InvariantCulture);
return options.IncludesOption(ObjectDisplayOptions.IncludeTypeSuffix) ? result + "F" : result;
}
示例6: ValidateOptions
private static void ValidateOptions(ObjectDisplayOptions options)
{
// These options are mutually exclusive in C# unless we're formatting a char...should not be passed otherwise...
Debug.Assert(!(options.IncludesOption(ObjectDisplayOptions.UseQuotes) && options.IncludesOption(ObjectDisplayOptions.UseHexadecimalNumbers)));
}
示例7: FormatString
internal override string FormatString(string str, ObjectDisplayOptions options)
{
return ObjectDisplay.FormatString(str, quote: options.IncludesOption(ObjectDisplayOptions.UseQuotes) ? '"' : '\0', escapeNonPrintable: false);
}