public ReflectionResult Get(string property) { var own = Reflection.AcquirePropertyInfo(property, this); if (own.PropertyInfo == null) { return(_freeFields.Get(property)); } try { var value = own.PropertyInfo.GetValue(this); return(new ReflectionResult { Full = true, Result = value }); } catch (Exception e) { return(new ReflectionResult { Full = true, ReflectionException = new ReflectionException(e.Message) }); } }
public object this[string property] { get { var own = Reflection.AcquirePropertyInfo(property, this); if (own.PropertyInfo != null) { return(own.PropertyInfo.GetValue(this)); } return(_freeFields[property]); } set { var own = Reflection.AcquirePropertyInfo(property, this); if (own.PropertyInfo != null) { own.PropertyInfo.SetValue(this, value); } else { _freeFields[property] = value; } } }
public object TryGet(string property) { var own = Reflection.AcquirePropertyInfo(property, this); return(own.PropertyInfo != null?own.PropertyInfo.GetValue(this) : _freeFields.TryGet(property)); }