Пример #1
0
        public ObjectInstance(ClrObject clrObject)
        {
            Address = new ObjectRef(clrObject.Address);
            Type    = new TypeRef(clrObject.Type.Name);
            var fields = new List <ObjectField>();

            foreach (var clrInstanceField in clrObject.Type.Fields)
            {
                object value = null;

                if (clrInstanceField.ElementType != ClrElementType.Object)
                {
                    value = clrInstanceField.GetValue(clrObject.Address);
                }
                else
                {
                    var address = (ulong)clrInstanceField.GetValue(clrObject.Address);
                    if (address != 0)
                    {
                        value = new ObjectRef(address);
                    }
                }

                fields.Add(new ObjectField(clrInstanceField.Name, value ?? NullValue.Instance));
            }

            Fields = fields.ToArray();
        }
Пример #2
0
        public ObjectArrayInstance(ClrObject clrObject)
        {
            var objectRefs = clrObject.Type.GetArrayLength(clrObject.Address);
            var objects    = new List <ObjectRef>();

            for (int i = 0; i < objectRefs; i++)
            {
                objects.Add(new ObjectRef(clrObject.Type.GetArrayElementAddress(clrObject.Address, i)));
            }

            Address  = new ObjectRef(clrObject.Address);
            Objects  = objects.ToArray();
            ItemType = new TypeRef(clrObject.Type.Name.Substring(0, clrObject.Type.Name.Length - 2));
        }