// Token: 0x06000237 RID: 567 RVA: 0x00003643 File Offset: 0x00001843 public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) : base(tail) { this.forType = forType; this.property = property; PropertyDecorator.SanityCheck(model, property, tail, out this.readOptionsWriteValue, true, true); this.shadowSetter = PropertyDecorator.GetShadowSetter(model, property); }
private static void SanityCheck(TypeModel model, PropertyInfo property, IProtoSerializer tail, out bool writeValue, bool nonPublic, bool allowInternal) { bool flag; if (property == null) { throw new ArgumentNullException("property"); } if (!tail.ReturnsValue) { flag = false; } else if (PropertyDecorator.GetShadowSetter(model, property) != null) { flag = true; } else { flag = (!property.CanWrite ? false : Helpers.GetSetMethod(property, nonPublic, allowInternal) != null); } writeValue = flag; if (!property.CanRead || Helpers.GetGetMethod(property, nonPublic, allowInternal) == null) { throw new InvalidOperationException("Cannot serialize property without a get accessor"); } if (!writeValue && (!tail.RequiresOldValue || Helpers.IsValueType(tail.ExpectedType))) { throw new InvalidOperationException(string.Concat("Cannot apply changes to property ", property.DeclaringType.FullName, ".", property.Name)); } }
// Token: 0x0600023C RID: 572 RVA: 0x0000F1F4 File Offset: 0x0000D3F4 internal static bool CanWrite(TypeModel model, MemberInfo member) { if (member == null) { throw new ArgumentNullException("member"); } PropertyInfo propertyInfo = member as PropertyInfo; if (propertyInfo != null) { return(propertyInfo.CanWrite || PropertyDecorator.GetShadowSetter(model, propertyInfo) != null); } return(member is FieldInfo); }
private static void SanityCheck(TypeModel model, PropertyInfo property, IProtoSerializer tail, out bool writeValue, bool nonPublic, bool allowInternal) { if (property == null) { throw new ArgumentNullException("property"); } writeValue = (tail.ReturnsValue && (PropertyDecorator.GetShadowSetter(model, property) != null || (property.get_CanWrite() && Helpers.GetSetMethod(property, nonPublic, allowInternal) != null))); if (!property.get_CanRead() || Helpers.GetGetMethod(property, nonPublic, allowInternal) == null) { throw new InvalidOperationException("Cannot serialize property without a get accessor"); } if (!writeValue && (!tail.RequiresOldValue || Helpers.IsValueType(tail.ExpectedType))) { throw new InvalidOperationException("Cannot apply changes to property " + property.get_DeclaringType().get_FullName() + "." + property.get_Name()); } }