/// <summary> /// Reads the specified object. /// </summary> /// <param name="obj">The object.</param> /// <returns></returns> /// <exception cref="ArgumentException">Obj has other than ID type.</exception> public static ID Read(ClrObject obj) { if (obj.IsNullObj) { return(null); } obj.ReEvaluateType(); if (obj.Type == null) { return(null); } if (!obj.Type.Name.Equals(typeof(ID).FullName, StringComparison.Ordinal)) { throw new ArgumentException("Obj has wrong " + obj.Type.Name + " instead of ID"); } ClrObject guidObject = obj.GetValueFld("_guid", false); if (guidObject.IsNullObj) { return(null); } return(new ID(ClrObjectValuesReader.ReadGuidValue(guidObject))); }
/// <summary> /// Maps the model fields. /// <para>Reads all interface fields and tries to get fields with same names in <paramref name="clrObject"/>. /// </para> /// </summary> /// <param name="model">The model.</param> /// <param name="clrObject">The CLR object.</param> private void MapModelFields(ref IClrObjMappingModel model, ClrObject clrObject) { // For safety. clrObject.ReEvaluateType(); model.Obj = clrObject; if (model.Obj.Type == null) { model = new ClrObjNoType { Obj = clrObject }; return; } foreach (FieldInfo fieldInfo in this.InjectableFldsCache[model]) { string violation; if (this.CanInjectField(fieldInfo, clrObject, out violation)) { this.MapFieldValueToModel(fieldInfo, clrObject, model); } else { model.BindingLog.AppendLine(violation); } } }
public override void Compute() { ClrAssert.ObjectNotNullTypeNotEmpty(this.Obj); this.Value = Obj.GetStringFld(fieldName: "_stringValue") ?? string.Empty; ClrObject multi = Obj.GetRefFld("_multiValue"); if (multi.IsNullObj) { return; } ClrObject arrayList = multi.GetRefFld("_entriesArray"); if (arrayList.IsNullObj) { return; } List <ClrObject> buckets = ClrCollectionHelper.EnumerateArrayList(arrayList); foreach (ClrObject bucket in buckets) { bucket.ReEvaluateType(); ClrObject val = bucket.GetRefFld("Value"); val.ReEvaluateType(); if (val.IsNullObj) { continue; } List <ClrObject> nestedValues = ClrCollectionHelper.EnumerateArrayList(val); foreach (ClrObject nestedValue in nestedValues) { nestedValue.ReEvaluateType(); if (nestedValue.IsNullObj || (nestedValue.Type == null)) { continue; } object tmpvalue = nestedValue.Type.GetValue(nestedValue.Address); if (tmpvalue is string) { this.Value += tmpvalue; } } } // var buckets = ClrCollectionHelper.EnumerateArrayOfRefTypes(arrayList); // buckets. }
public static Dictionary <ClrObject, ClrObject> Read(ClrObject obj, string fldName) { if (obj.IsNullObj) { return(null); } obj.ReEvaluateType(); if (obj.Type == null) { return(null); } ClrObject fld = obj.GetRefFld(fldName); return(Read(fld)); }
public static Dictionary <ClrObject, ClrObject> Read(ClrObject obj) { if (obj.IsNullObj) { return(null); } obj.ReEvaluateType(); if (obj.Type == null) { return(null); } ClrObject hashtable = obj.GetRefFld("_hashtable"); return(HashtableReader.ReadClrObjects(hashtable)); }
public override IEnumerable <ClrObject> EnumerateObjectsFromSource([NotNull] ClrRuntime runtime) { Assert.ArgumentNotNull(runtime, "runtime"); var yielded = new HashSet <ulong>(); ClrHeap heap = runtime.GetHeap(); foreach (var threadObj in base.EnumerateObjectsFromSource(runtime)) { var thread = runtime.Threads.FirstOrDefault(t => t.Address == threadObj.Address); if (thread == null) { continue; } foreach (ClrRoot root in thread.EnumerateStackObjects(this.IncludePossiblyDead)) { var clrObj = new ClrObject(root.Object, heap); clrObj.ReEvaluateType(); if (clrObj.IsNullObj || (clrObj.Type == null)) { continue; } if (yielded.Contains(clrObj.Address)) { continue; } yielded.Add(clrObj.Address); yield return(clrObj); } } }