Пример #1
0
        public static object GetValue(ClrType type, ClrElementKind typeKind, ClrInstanceField field, ClrElementKind fldKind, ClrHeap heap, ulong addr, bool intr)
        {
            Debug.Assert(!TypeExtractor.IsUnknownStruct(typeKind) && !TypeExtractor.IsUnknownStruct(fldKind));
            if (TypeExtractor.IsAmbiguousKind(fldKind))
            {
                if (TypeExtractor.IsString(typeKind))
                {
                    var faddr = ValueExtractor.ReadUlongAtAddress(addr, heap);
                    return(ValueExtractor.GetStringAtAddress(faddr, heap));
                }

                if (TypeExtractor.IsKnownStruct(fldKind))
                {
                    switch (TypeExtractor.GetSpecialKind(fldKind))
                    {
                    case ClrElementKind.Decimal:
                        return(ValueExtractor.GetDecimalValue(addr, type));

                    case ClrElementKind.DateTime:
                        return(ValueExtractor.DateTimeValue(addr, type));

                    case ClrElementKind.TimeSpan:
                        return(ValueExtractor.TimeSpanValue(addr, type));

                    case ClrElementKind.Guid:
                        return(ValueExtractor.GuidValue(addr, type));

                    default:
                        return(Constants.DontKnowHowToGetValue);
                    }
                }

                if (TypeExtractor.IsPrimitive(typeKind))
                {
                    return(ValueExtractor.PrimitiveValueAsString(addr, type, typeKind));
                }
                if (TypeExtractor.IsObjectReference(typeKind))
                {
                    return(field.GetValue(addr, intr, false));
                }
                return(Constants.DontKnowHowToGetValue);
            }

            if (TypeExtractor.IsString(fldKind))
            {
                return(ValueExtractor.GetStringAtAddress(addr, intr, field));
            }

            if (TypeExtractor.IsKnownStruct(fldKind))
            {
                switch (TypeExtractor.GetSpecialKind(fldKind))
                {
                case ClrElementKind.Decimal:
                    return(ValueExtractor.GetDecimalPAF(addr, field, intr));

                case ClrElementKind.DateTime:
                    return(ValueExtractor.GetDateTimePAF(addr, field, intr));

                case ClrElementKind.TimeSpan:
                    return(ValueExtractor.GetTimeSpan(addr, field, intr));

                case ClrElementKind.Guid:
                    return(ValueExtractor.GetGuid(addr, field, intr));

                default:
                    return(Constants.DontKnowHowToGetValue);
                }
            }
            if (TypeExtractor.IsPrimitive(fldKind))
            {
                return(ValueExtractor.GetPrimitiveValueObject(addr, field, intr));
            }
            if (TypeExtractor.IsObjectReference(fldKind))
            {
                return(field.GetValue(addr, intr, false));
            }

            return(Constants.DontKnowHowToGetValue);
        }