public override object Read(object value, ProtoReader source) { Helpers.DebugAssert(value != null); object oldVal = Tail.RequiresOldValue ? _accessors.Get != null?_accessors.Get(value) : Helpers.GetPropertyValue(_property, value) : null; object newVal = Tail.Read(oldVal, source); if (_canSetInRuntime && (!Tail.RequiresOldValue // always set where can't check oldVal // and if it's value type or nullable with changed null/not null or ref || (Helpers.IsValueType(_property.PropertyType) && oldVal != null && newVal != null) || !ReferenceEquals(oldVal, newVal) )) { if (_accessors.Set != null) { _accessors.Set(value, newVal); } else { if (_shadowSetter == null) { _property.SetValue(value, newVal, null); } else { _shadowSetter.Invoke(value, new object[] { newVal }); } } } return(value); }
object GetValue(object instance) { return(_accessors.Get != null?_accessors.Get(instance) : _field.GetValue(instance)); }