本文整理汇总了C#中Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue.GetFieldValue方法的典型用法代码示例。如果您正苦于以下问题:C# DkmClrValue.GetFieldValue方法的具体用法?C# DkmClrValue.GetFieldValue怎么用?C# DkmClrValue.GetFieldValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation.DkmClrValue
的用法示例。
在下文中一共展示了DkmClrValue.GetFieldValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: GetValueAndFullName
private static DkmClrValue GetValueAndFullName(
IDkmClrFullNameProvider fullNameProvider,
DkmInspectionContext inspectionContext,
DkmClrValue value,
Field field,
string parentFullName,
out string fullName)
{
var parent = field.Parent;
if (parent != null)
{
value = GetValueAndFullName(
fullNameProvider,
inspectionContext,
value,
parent,
parentFullName,
out parentFullName);
}
var fieldName = field.FieldInfo.Name;
fullName = (parentFullName == null) ?
null :
fullNameProvider.GetClrMemberName(
inspectionContext,
parentFullName,
declaringType: field.DeclaringTypeAndInfo.ClrType,
declaringTypeInfo: null,
memberName: fieldName,
memberAccessRequiresExplicitCast: false,
memberIsStatic: false);
return value.GetFieldValue(fieldName, inspectionContext);
}
示例4: CreateExpansion
internal static Expansion CreateExpansion(
DkmInspectionContext inspectionContext,
TypeAndCustomInfo declaredTypeAndInfo,
DkmClrValue value,
ExpansionFlags flags,
Predicate<MemberInfo> predicate,
ResultProvider resultProvider)
{
// For members of type DynamicProperty (part of Dynamic View expansion), we want
// to expand the underlying value (not the members of the DynamicProperty type).
var type = value.Type;
var isDynamicProperty = type.GetLmrType().IsDynamicProperty();
if (isDynamicProperty)
{
Debug.Assert(!value.IsNull);
value = value.GetFieldValue("value", inspectionContext);
}
var runtimeType = type.GetLmrType();
// Primitives, enums, function pointers, and null values with a declared type that is an interface have no visible members.
Debug.Assert(!runtimeType.IsInterface || value.IsNull);
if (resultProvider.IsPrimitiveType(runtimeType) || runtimeType.IsEnum || runtimeType.IsInterface || runtimeType.IsFunctionPointer())
{
return null;
}
// As in the old C# EE, DynamicProperty members are only expandable if they have a Dynamic View expansion.
var dynamicViewExpansion = DynamicViewExpansion.CreateExpansion(inspectionContext, value, resultProvider);
if (isDynamicProperty && (dynamicViewExpansion == null))
{
return null;
}
var customTypeInfoMap = CustomTypeInfoTypeArgumentMap.Create(declaredTypeAndInfo);
var expansions = ArrayBuilder<Expansion>.GetInstance();
// From the members, collect the fields and properties,
// separated into static and instance members.
var staticMembers = ArrayBuilder<MemberAndDeclarationInfo>.GetInstance();
var instanceMembers = ArrayBuilder<MemberAndDeclarationInfo>.GetInstance();
var appDomain = value.Type.AppDomain;
// Expand members. (Ideally, this should be done lazily.)
var allMembers = ArrayBuilder<MemberAndDeclarationInfo>.GetInstance();
var includeInherited = (flags & ExpansionFlags.IncludeBaseMembers) == ExpansionFlags.IncludeBaseMembers;
var hideNonPublic = (inspectionContext.EvaluationFlags & DkmEvaluationFlags.HideNonPublicMembers) == DkmEvaluationFlags.HideNonPublicMembers;
runtimeType.AppendTypeMembers(allMembers, predicate, declaredTypeAndInfo.Type, appDomain, includeInherited, hideNonPublic);
foreach (var member in allMembers)
{
var name = member.Name;
if (name.IsCompilerGenerated())
{
continue;
}
if (member.IsStatic)
{
staticMembers.Add(member);
}
else if (!value.IsNull)
{
instanceMembers.Add(member);
}
}
allMembers.Free();
// Public and non-public instance members.
Expansion publicInstanceExpansion;
Expansion nonPublicInstanceExpansion;
GetPublicAndNonPublicMembers(
instanceMembers,
customTypeInfoMap,
out publicInstanceExpansion,
out nonPublicInstanceExpansion);
// Public and non-public static members.
Expansion publicStaticExpansion;
Expansion nonPublicStaticExpansion;
GetPublicAndNonPublicMembers(
staticMembers,
customTypeInfoMap,
out publicStaticExpansion,
out nonPublicStaticExpansion);
if (publicInstanceExpansion != null)
{
expansions.Add(publicInstanceExpansion);
}
if ((publicStaticExpansion != null) || (nonPublicStaticExpansion != null))
{
var staticExpansions = ArrayBuilder<Expansion>.GetInstance();
if (publicStaticExpansion != null)
{
staticExpansions.Add(publicStaticExpansion);
}
if (nonPublicStaticExpansion != null)
{
//.........这里部分代码省略.........
示例5: 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;
}