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


C# ObjectDisplayOptions类代码示例

本文整理汇总了C#中ObjectDisplayOptions的典型用法代码示例。如果您正苦于以下问题:C# ObjectDisplayOptions类的具体用法?C# ObjectDisplayOptions怎么用?C# ObjectDisplayOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetArrayDisplayString

        internal override string GetArrayDisplayString(Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options)
        {
            Debug.Assert(lmrType.IsArray);

            Type originalLmrType = lmrType;

            // Strip off all array types.  We'll process them at the end.
            while (lmrType.IsArray)
            {
                lmrType = lmrType.GetElementType();
            }

            var pooled = PooledStringBuilder.GetInstance();
            var builder = pooled.Builder;
            builder.Append('{');

            // We're showing the type of a value, so "dynamic" does not apply.
            bool unused;
            builder.Append(GetTypeName(new TypeAndCustomInfo(lmrType), escapeKeywordIdentifiers: false, sawInvalidIdentifier: out unused)); // NOTE: call our impl directly, since we're coupled anyway.

            var numSizes = sizes.Count;

            builder.Append('[');
            for (int i = 0; i < numSizes; i++)
            {
                if (i > 0)
                {
                    builder.Append(", ");
                }
                var lowerBound = lowerBounds[i];
                var size = sizes[i];
                if (lowerBound == 0)
                {
                    builder.Append(FormatLiteral(size, options));
                }
                else
                {
                    builder.Append(FormatLiteral(lowerBound, options));
                    builder.Append("..");
                    builder.Append(FormatLiteral(size + lowerBound - 1, options));
                }
            }
            builder.Append(']');

            lmrType = originalLmrType.GetElementType(); // Strip off one layer (already handled).
            while (lmrType.IsArray)
            {
                builder.Append('[');
                builder.Append(',', lmrType.GetArrayRank() - 1);
                builder.Append(']');

                lmrType = lmrType.GetElementType();
            }

            builder.Append('}');
            return pooled.ToStringAndFree();
        }
开发者ID:sebgod,项目名称:roslyn,代码行数:57,代码来源:CSharpFormatter.Values.cs

示例2: FormatLiteral

 internal override string FormatLiteral(int value, ObjectDisplayOptions options)
 {
     return ObjectDisplay.FormatLiteral(value, options & ~ObjectDisplayOptions.UseQuotes);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:CSharpFormatter.Values.cs

示例3: FormatLiteral

        internal static string FormatLiteral(ulong value, ObjectDisplayOptions options)
        {
            var pooledBuilder = PooledStringBuilder.GetInstance();
            var sb = pooledBuilder.Builder;

            if (options.IncludesOption(ObjectDisplayOptions.UseHexadecimalNumbers))
            {
                sb.Append("0x");
                sb.Append(value.ToString("x16"));
            }
            else
            {
                sb.Append(value.ToString(CultureInfo.InvariantCulture));
            }

            if (options.IncludesOption(ObjectDisplayOptions.IncludeTypeSuffix))
            {
                sb.Append("UL");
            }

            return pooledBuilder.ToStringAndFree();
        }
开发者ID:sebgod,项目名称:roslyn,代码行数:22,代码来源:ObjectDisplay.cs

示例4: FormatLiteral

 internal override string FormatLiteral(char c, ObjectDisplayOptions options)
 {
     return ObjectDisplay.FormatLiteral(c, options);
 }
开发者ID:sebgod,项目名称:roslyn,代码行数:4,代码来源:CSharpFormatter.Values.cs

示例5: FormatPrimitiveObject

 internal override string FormatPrimitiveObject(object value, ObjectDisplayOptions options)
 {
     return ObjectDisplay.FormatPrimitive(value, options);
 }
开发者ID:sebgod,项目名称:roslyn,代码行数:4,代码来源:CSharpFormatter.Values.cs

示例6: GetEnumDisplayString

#pragma warning disable RS0010
        /// <remarks>
        /// The corresponding native code is in EEUserStringBuilder::ErrTryAppendConstantEnum.
        /// The corresponding roslyn code is in 
        /// <see cref="M:Microsoft.CodeAnalysis.SymbolDisplay.AbstractSymbolDisplayVisitor`1.AddEnumConstantValue(Microsoft.CodeAnalysis.INamedTypeSymbol, System.Object, System.Boolean)"/>.
        /// NOTE: no curlies for enum values.
        /// </remarks>
#pragma warning restore RS0010
        private string GetEnumDisplayString(Type lmrType, DkmClrValue value, ObjectDisplayOptions options, bool includeTypeName, DkmInspectionContext inspectionContext)
        {
            Debug.Assert(lmrType.IsEnum);
            Debug.Assert(value != null);

            object underlyingValue = value.HostObjectValue;
            Debug.Assert(underlyingValue != null);

            string displayString;

            ArrayBuilder<EnumField> fields = ArrayBuilder<EnumField>.GetInstance();
            FillEnumFields(fields, lmrType);
            // We will normalize/extend all enum values to ulong to ensure that we are always comparing the full underlying value.
            ulong valueForComparison = ConvertEnumUnderlyingTypeToUInt64(underlyingValue, Type.GetTypeCode(lmrType));
            var typeToDisplayOpt = includeTypeName ? lmrType : null;
            if (valueForComparison != 0 && IsFlagsEnum(lmrType))
            {
                displayString = GetNamesForFlagsEnumValue(fields, underlyingValue, valueForComparison, options, typeToDisplayOpt);
            }
            else
            {
                displayString = GetNameForEnumValue(fields, underlyingValue, valueForComparison, options, typeToDisplayOpt);
            }
            fields.Free();

            return displayString ?? FormatPrimitive(value, options, inspectionContext);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:35,代码来源:Formatter.Values.cs

示例7: GetValueString

        internal string GetValueString(DkmClrValue value, DkmInspectionContext inspectionContext, ObjectDisplayOptions options, GetValueFlags flags)
        {
            if (value.IsError())
            {
                return (string)value.HostObjectValue;
            }

            if (UsesHexadecimalNumbers(inspectionContext))
            {
                options |= ObjectDisplayOptions.UseHexadecimalNumbers;
            }

            var lmrType = value.Type.GetLmrType();
            if (IsPredefinedType(lmrType) && !lmrType.IsObject())
            {
                if (lmrType.IsString())
                {
                    var stringValue = (string)value.HostObjectValue;
                    if (stringValue == null)
                    {
                        return _nullString;
                    }
                    return IncludeObjectId(
                        value,
                        FormatString(stringValue, options),
                        flags);
                }
                else if (lmrType.IsCharacter())
                {
                    return IncludeObjectId(
                        value,
                        FormatLiteral((char)value.HostObjectValue, options | ObjectDisplayOptions.IncludeCodePoints),
                        flags);
                }
                else
                {
                    return IncludeObjectId(
                        value,
                        FormatPrimitive(value, options & ~ObjectDisplayOptions.UseQuotes, inspectionContext),
                        flags);
                }
            }
            else if (value.IsNull && !lmrType.IsPointer)
            {
                return _nullString;
            }
            else if (lmrType.IsEnum)
            {
                return IncludeObjectId(
                    value,
                    GetEnumDisplayString(lmrType, value, options, (flags & GetValueFlags.IncludeTypeName) != 0, inspectionContext),
                    flags);
            }
            else if (lmrType.IsArray)
            {
                return IncludeObjectId(
                    value,
                    GetArrayDisplayString(lmrType, value.ArrayDimensions, value.ArrayLowerBounds, options),
                    flags);
            }
            else if (lmrType.IsPointer)
            {
                // NOTE: the HostObjectValue will have a size corresponding to the process bitness
                // and FormatPrimitive will adjust accordingly.
                var tmp = FormatPrimitive(value, ObjectDisplayOptions.UseHexadecimalNumbers, inspectionContext); // Always in hex.
                Debug.Assert(tmp != null);
                return tmp;
            }
            else if (lmrType.IsNullable())
            {
                var nullableValue = value.GetNullableValue(inspectionContext);
                // It should be impossible to nest nullables, so this recursion should introduce only a single extra stack frame.
                return nullableValue == null
                    ? _nullString
                    : GetValueString(nullableValue, inspectionContext, ObjectDisplayOptions.None, GetValueFlags.IncludeTypeName);
            }

            // "value.EvaluateToString()" will check "Call string-conversion function on objects in variables windows"
            // (Tools > Options setting) and call "value.ToString()" if appropriate.
            return IncludeObjectId(
                value,
                string.Format(_defaultFormat, value.EvaluateToString(inspectionContext) ?? inspectionContext.GetTypeName(value.Type, CustomTypeInfo: null, FormatSpecifiers: NoFormatSpecifiers)),
                flags);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:84,代码来源:Formatter.Values.cs

示例8: FormatLiteral

        internal static string FormatLiteral(decimal value, ObjectDisplayOptions options, CultureInfo cultureInfo = null)
        {
            var result = value.ToString(GetFormatCulture(cultureInfo));

            return options.IncludesOption(ObjectDisplayOptions.IncludeTypeSuffix) ? result + "M" : result;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:6,代码来源:ObjectDisplay.cs

示例9: GetValueStringForCharacter

 /// <summary>
 /// Gets the string representation of a character literal without including the numeric code point.
 /// </summary>
 internal string GetValueStringForCharacter(DkmClrValue value, DkmInspectionContext inspectionContext, ObjectDisplayOptions options)
 {
     Debug.Assert(value.Type.GetLmrType().IsCharacter());
     if (UsesHexadecimalNumbers(inspectionContext))
     {
         options |= ObjectDisplayOptions.UseHexadecimalNumbers;
     }
     var charTemp = FormatLiteral((char)value.HostObjectValue, options);
     Debug.Assert(charTemp != null);
     return charTemp;
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:14,代码来源:Formatter.Values.cs

示例10: FormatString

 internal override string FormatString(string str, ObjectDisplayOptions options)
 {
     return ObjectDisplay.FormatString(str, useQuotes: options.IncludesOption(ObjectDisplayOptions.UseQuotes));
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:CSharpFormatter.Values.cs

示例11: GetNamesForFlagsEnumValue

        internal override string GetNamesForFlagsEnumValue(ArrayBuilder<EnumField> fields, object value, ulong underlyingValue, ObjectDisplayOptions options, Type typeToDisplayOpt)
        {
            var usedFields = ArrayBuilder<EnumField>.GetInstance();
            FillUsedEnumFields(usedFields, fields, underlyingValue);

            if (usedFields.Count == 0)
            {
                return null;
            }

            var pooled = PooledStringBuilder.GetInstance();
            var builder = pooled.Builder;

            for (int i = usedFields.Count - 1; i >= 0; i--) // Backwards to list smallest first.
            {
                AppendEnumTypeAndName(builder, typeToDisplayOpt, usedFields[i].Name);

                if (i > 0)
                {
                    builder.Append(" | ");
                }
            }

            usedFields.Free();

            return pooled.ToStringAndFree();
        }
开发者ID:sebgod,项目名称:roslyn,代码行数:27,代码来源:CSharpFormatter.Values.cs

示例12: FormatPrimitive

        internal string FormatPrimitive(DkmClrValue value, ObjectDisplayOptions options, DkmInspectionContext inspectionContext)
        {
            Debug.Assert(value != null);

            object obj;
            if (value.Type.GetLmrType().IsDateTime())
            {
                DkmClrValue dateDataValue = value.GetFieldValue(DateTimeUtilities.DateTimeDateDataFieldName, inspectionContext);
                Debug.Assert(dateDataValue.HostObjectValue != null);

                obj = DateTimeUtilities.ToDateTime((ulong)dateDataValue.HostObjectValue);
            }
            else
            {
                Debug.Assert(value.HostObjectValue != null);
                obj = value.HostObjectValue;
            }

            return FormatPrimitiveObject(obj, options);
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:20,代码来源:Formatter.Values.cs

示例13: GetNameForEnumValue

        internal override string GetNameForEnumValue(ArrayBuilder<EnumField> fields, object value, ulong underlyingValue, ObjectDisplayOptions options, Type typeToDisplayOpt)
        {
            foreach (var field in fields)
            {
                // First match wins (deterministic since sorted).
                if (underlyingValue == field.Value)
                {
                    var pooled = PooledStringBuilder.GetInstance();
                    var builder = pooled.Builder;

                    AppendEnumTypeAndName(builder, typeToDisplayOpt, field.Name);

                    return pooled.ToStringAndFree();
                }
            }

            return null;
        }
开发者ID:sebgod,项目名称:roslyn,代码行数:18,代码来源:CSharpFormatter.Values.cs

示例14: GetArrayDisplayString

 internal abstract string GetArrayDisplayString(Type lmrType, ReadOnlyCollection<int> sizes, ReadOnlyCollection<int> lowerBounds, ObjectDisplayOptions options);
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:1,代码来源:Formatter.Values.cs

示例15: GetNameForEnumValue

 internal abstract string GetNameForEnumValue(ArrayBuilder<EnumField> fields, object value, ulong underlyingValue, ObjectDisplayOptions options, Type typeToDisplayOpt);
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:1,代码来源:Formatter.Values.cs


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