Esempio n. 1
0
 protected virtual ClrObject[] EnumerateArrayOfClassInstances(ClrObject clrObject)
 {
     try
     {
         return(ClrCollectionHelper.EnumerateArrayOfRefTypes(clrObject).ToArray());
     }
     catch (Exception)
     {
         return(ExecuteFallbackLogic(clrObject));
     }
 }
Esempio n. 2
0
        public override IClrObjMappingModel ReadEntity(ClrObject obj, ModelMapperFactory factory)
        {
            ClrObject tablesFld = obj.GetRefFld("m_tables");

            ClrObject bucketsFld = tablesFld.GetRefFld("m_buckets");
            ClrType   type       = bucketsFld.Type;
            ClrHeap   heap       = type.Heap;

            IEnumerable <ClrObject> values = ClrCollectionHelper.EnumerateArrayOfRefTypes(bucketsFld).Where(t => !t.IsNullObj);


            ClrInstanceField valueField = type.ComponentType.GetFieldByName("m_value");

            ClrInstanceField keyField = type.ComponentType.GetFieldByName("m_key");
            var hashtableModel        = new HashtableMappingModel
            {
                Obj = obj
            };

            foreach (ClrObject val in values)
            {
                ClrObject keyObj = val.GetRefFld("m_key");
                if (keyObj.IsNullObj)
                {
                    continue;
                }

                ClrObject valObj = val.GetRefFld("m_value");

                hashtableModel.Elements.Add(
                    key: factory.BuildModel(keyObj),
                    value: factory.BuildModel(valObj));
            }

            return(hashtableModel);
        }