// Load serialized data into object public void Load(object obj) { if (!PropertySchema.IsLoadable) { TypeRepo.LoadLazyObjectRef(); // skip reference if (LazyProperty != null) { LazyProperty.FieldInfoLoaded.SetValue(obj, true); } } else if (LazyProperty != null) { TypeRef typeRef = TypeRepo.LoadLazyObjectRef(); LazyProperty.SetTypeRef(obj, typeRef); } else { object valueObject = TypeRepo.LoadObjectRef(); // can throw System.ArgumentException, set to null if not Loadable? // Should we add exception handling or detect this earlier when we load the schema? // Don't set the property if it's already set to the default, some objects track property assignments if (TypeRepo.TypeSchema.IsPrimitive) { // todo: construct temp object and store default instead for speed? dynamic currentValue = PropertySchema.PropertyInfo.GetValue(obj); if ((dynamic)valueObject == currentValue) { return; } } PropertySchema.PropertyInfo.SetValue(obj, valueObject); } }
public override void LoadObjectData(object obj) { //(IEnumerable<listTypeRepo.type>)objects[i]; int count = Reader.ReadInt32(); for (int j = 0; j < count; j++) { object objectValue = _listTypeRepo.LoadObjectRef(); _addMethod.Invoke(obj, new object[] { objectValue }); } }
public override void LoadObjectData(object obj) { // Can't use Activator because Array requires parameters in it's constructor IList iList = (IList)obj; for (int j = 0; j < iList.Count; j++) { object item = _listTypeRepo.LoadObjectRef(); iList[j] = item; } }
public void Load(object obj) { if (FieldSchema.IsLoadable) { object valueObject = TypeRepo.LoadObjectRef(); // todo: 36% of current cpu usage, break into explicit operators? (is that even possible?) FieldSchema.FieldInfo.SetValue(obj, valueObject); // else set to null? } else { TypeRepo.SkipObjectRef(); } }
public override void LoadObjectData(object obj) { IDictionary iCollection = (IDictionary)obj; int count = Reader.ReadInt32(); for (int j = 0; j < count; j++) { object key = _list1TypeRepo.LoadObjectRef(); object value = _list2TypeRepo.LoadObjectRef(); if (key != null) { _addMethod.Invoke(iCollection, new object[] { key, value }); } } }
public override void LoadObjectData(object obj) { IList iList = (IList)obj; int count = Reader.ReadInt32(); if (_propertyInfoCapacity != null) { _propertyInfoCapacity.SetValue(iList, count); } for (int j = 0; j < count; j++) { object valueObject = _listTypeRepo.LoadObjectRef(); iList.Add(valueObject); } }