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


C# DkmClrValue.EvaluateToString方法代码示例

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


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

示例1: GetUnderlyingStringImpl

        private string GetUnderlyingStringImpl(DkmClrValue value, DkmInspectionContext inspectionContext)
        {
            Debug.Assert(!value.IsError());

            if (value.IsNull)
            {
                return null;
            }

            var lmrType = value.Type.GetLmrType();
            if (lmrType.IsEnum || lmrType.IsArray || lmrType.IsPointer)
            {
                return null;
            }

            if (lmrType.IsNullable())
            {
                var nullableValue = value.GetNullableValue(inspectionContext);
                return nullableValue != null ? GetUnderlyingStringImpl(nullableValue, inspectionContext) : null;
            }

            if (lmrType.IsString())
            {
                return (string)value.HostObjectValue;
            }
            else if (!IsPredefinedType(lmrType))
            {
                // Check for special cased non-primitives that have underlying strings
                if (lmrType.IsType("System.Data.SqlTypes", "SqlString"))
                {
                    var fieldValue = value.GetFieldValue(InternalWellKnownMemberNames.SqlStringValue, inspectionContext);
                    return fieldValue.HostObjectValue as string;
                }
                else if (lmrType.IsOrInheritsFrom("System.Xml.Linq", "XNode"))
                {
                    return value.EvaluateToString(inspectionContext);
                }
            }

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

示例2: 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

示例3: GetUnderlyingStringImpl

        private string GetUnderlyingStringImpl(DkmClrValue value)
        {
            if (value.IsNull)
            {
                return null;
            }

            var lmrType = value.Type.GetLmrType();
            if (lmrType.IsEnum || lmrType.IsArray || lmrType.IsPointer)
            {
                return null;
            }

            if (lmrType.IsNullable())
            {
                var nullableValue = value.GetNullableValue();
                return nullableValue != null ? GetUnderlyingStringImpl(nullableValue) : null;
            }

            if (lmrType.IsString())
            {
                return (string)value.HostObjectValue;
            }
            else if (!IsPredefinedType(lmrType))
            {
                // Check for special cased non-primitives that have underlying strings
                if (string.Equals(lmrType.FullName, "System.Data.SqlTypes.SqlString", StringComparison.Ordinal))
                {
                    var fieldValue = value.GetFieldValue(InternalWellKnownMemberNames.SqlStringValue);
                    return fieldValue.HostObjectValue as string;
                }

                do
                {
                    if (string.Equals(lmrType.FullName, "System.Xml.Linq.XNode", StringComparison.Ordinal))
                    {
                        return value.EvaluateToString();
                    }

                    lmrType = lmrType.BaseType;
                }
                while (lmrType != null);
            }

            return null;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:46,代码来源:Formatter.Values.cs


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