public static string GetSimpleValueString(ClrObject obj) { object value = obj.SimpleValue; if (value == null) { return("null"); } ClrType type = obj.Type; if (type != null && type.IsEnum) { return(type.GetEnumName(value) ?? value.ToString()); } DateTime?dateTime = value as DateTime?; if (dateTime != null) { return(GetDateTimeString(dateTime.Value)); } return(value.ToString()); }
public override object GetValue(ClrObject o) { return(new DictionaryVisual { Count = (int)o.Dynamic.count - (int)o.Dynamic.freeCount, Items = from entry in o["entries"] where (int)entry["hashCode"] > 0 select new KeyValuePair <ClrObject, ClrObject>(entry["key"], entry["value"]) }); }
public static object GetSimpleValue(ClrObject obj) { if (obj.IsNull()) { return(null); } ClrType type = obj.Type; ClrHeap heap = type.Heap; if (type.IsPrimitive || type.IsString) { return(type.GetValue(obj.Address)); } ulong address = obj.IsInterior ? obj.Address : obj.Address + (ulong)heap.PointerSize; switch (type.Name) { case GuidTypeName: { byte[] buffer = ReadBuffer(heap, address, 16); return(new Guid(buffer)); } case TimeSpanTypeName: { byte[] buffer = ReadBuffer(heap, address, 8); long ticks = BitConverter.ToInt64(buffer, 0); return(new TimeSpan(ticks)); } case DateTimeTypeName: { byte[] buffer = ReadBuffer(heap, address, 8); ulong dateData = BitConverter.ToUInt64(buffer, 0); return(GetDateTime(dateData)); } case IPAddressTypeName: { return(GetIPAddress(obj)); } } throw new InvalidOperationException(string.Format("SimpleValue not available for type '{0}'", type.Name)); }
private static IPAddress GetIPAddress(ClrObject ipAddress) { const int AddressFamilyInterNetworkV6 = 23; const int IPv4AddressBytes = 4; const int IPv6AddressBytes = 16; const int NumberOfLabels = IPv6AddressBytes / 2; byte[] bytes; int family = (int)ipAddress["m_Family"].SimpleValue; if (family == AddressFamilyInterNetworkV6) { bytes = new byte[IPv6AddressBytes]; int j = 0; var numbers = ipAddress["m_Numbers"]; for (int i = 0; i < NumberOfLabels; i++) { ushort number = (ushort)numbers[i].SimpleValue; bytes[j++] = (byte)((number >> 8) & 0xFF); bytes[j++] = (byte)(number & 0xFF); } } else { long address = (long)ipAddress["m_Address"].SimpleValue; bytes = new byte[IPv4AddressBytes]; bytes[0] = (byte)(address); bytes[1] = (byte)(address >> 8); bytes[2] = (byte)(address >> 16); bytes[3] = (byte)(address >> 24); } return(new IPAddress(bytes)); }
public IEnumerable <ClrObject> GetReferenceBy(ClrObject o) { return(m_referenceMap.GetReferenceBy(o)); }
public ClrObjectWrapper(ClrObject item) { Object = item; }
public static ClrObjectWrapper Wrap(this ClrObject item) { return(new ClrObjectWrapper(item)); }
public static ClrObject DowncastToBase(this ClrObject clrObject) { return(clrObject?.Type?.BaseType != null ? new ClrObject(clrObject.Address, clrObject.Type.BaseType) : null); }
public ClrDynamic(ClrObject obj) : this(obj.Address, obj.Type, false) { }
public abstract object GetValue(ClrObject o);