public object ReadSerializationData(RuntimeSerializationInfo _info) { stringField = _info.GetValue <string>("string"); intField = _info.GetValue <int>("int"); floatField = _info.GetValue <float>("float"); dateTimeField = _info.GetValue <DateTime>("date-time"); return(this); }
public object ReadSerializationData(RuntimeSerializationInfo _info) { stringField = _info.GetValue<string>("string"); intField = _info.GetValue<int>("int"); floatField = _info.GetValue<float>("float"); dateTimeField = _info.GetValue<DateTime>("date-time"); return this; }
private object SetObjectDataUsingReflection(object _object, Type _objectType, RuntimeSerializationInfo _serializationInfo, RuntimeSerializableAttribute _serializableAttr) { List <Field> _serializableFields = SerializationTypeUtil.GetRuntimeSerializableFields(_objectType, _serializableAttr); int _serializableFieldCount = _serializableFields.Count; // Iterate through all serialisable fields for (int _iter = 0; _iter < _serializableFieldCount; _iter++) { Field _curField = _serializableFields[_iter]; FieldInfo _curFieldInfo = _curField.Info; object _curFieldValue = _serializationInfo.GetValue(_curFieldInfo.Name, _curFieldInfo.FieldType, _curField.IsObjectInitializer); // Set this new value if (_curFieldInfo.IsStatic) { _curFieldInfo.SetValue(null, _curFieldValue); } else { _curFieldInfo.SetValue(_object, _curFieldValue); } } return(_object); }
private object SetObjectDataUsingReflection(object _object, Type _objectType, RuntimeSerializationInfo _serializationInfo, RuntimeSerializableAttribute _serializableAttr) { List<Field> _serializableFields = SerializationTypeUtil.GetRuntimeSerializableFields(_objectType, _serializableAttr); int _serializableFieldCount = _serializableFields.Count; // Iterate through all serialisable fields for (int _iter = 0; _iter < _serializableFieldCount; _iter++) { Field _curField = _serializableFields[_iter]; FieldInfo _curFieldInfo = _curField.Info; object _curFieldValue = _serializationInfo.GetValue(_curFieldInfo.Name, _curFieldInfo.FieldType, _curField.IsObjectInitializer); // Set this new value if (_curFieldInfo.IsStatic) _curFieldInfo.SetValue(null, _curFieldValue); else _curFieldInfo.SetValue(_object, _curFieldValue); } return _object; }