Пример #1
0
        public static Dictionary <ClrObject, ClrObject> ReadClrObjects(ClrObject obj)
        {
            if (obj.Type == null)
            {
                return(new Dictionary <ClrObject, ClrObject>());
            }

            ClrObject buckets = obj.GetRefFld("buckets", false);

            if (buckets.Type == null)
            {
                return(new Dictionary <ClrObject, ClrObject>());
            }

            List <Tuple <ClrObject, ClrObject> > enumerated = ClrCollectionHelper.EnumerateHashtable(obj);

            var dict = new Dictionary <ClrObject, ClrObject>(enumerated.Count);

            foreach (var tuple in enumerated)
            {
                dict.Add(tuple.Item1, tuple.Item2);
            }

            return(dict);
        }
Пример #2
0
        public override IClrObjMappingModel ReadEntity(ClrObject obj, ModelMapperFactory factory)
        {
            ClrObject fld = obj.GetRefFld(entriesTableFldName);
            List <Tuple <ClrObject, ClrObject> > values = ClrCollectionHelper.EnumerateHashtable(fld);

            var hashtable = new Hashtable(values.Count);

            foreach (var keyValuePair in values)
            {
                ClrObject val = keyValuePair.Item2;
                if (val.IsNullObj)
                {
                    continue;
                }


                var       key   = val.GetStringFld("Key");
                ClrObject value = val.GetRefFld("Value");

                if (key == null || value.IsNullObj)
                {
                    continue;
                }

                IClrObjMappingModel valModel = factory.BuildModel(value);
                hashtable.Add(key, valModel);
            }

            var hashTableMapping = new HashtableMappingModel(hashtable, obj);

            return(hashTableMapping);
        }