public object Get(object source) { object target = source; for (int n = 0; n < _properties.Length; n++) { SettableInfo property = _properties[n]; target = property.GetValue(target); if ((n != _properties.Length - 1) && target == null) { target = TryToCreateTarget(property.PropertyType); } } return(target); }
public void Set(object target, object value) { for (int n = 0; n < _properties.Length; n++) { SettableInfo property = _properties[n]; if (n == _properties.Length - 1) { property.SetValue(target, value); } else { object lastTarget = target; target = property.GetValue(target); if (target == null) { target = TryToCreateTarget(property.PropertyType); property.SetValue(lastTarget, target); } } } }