/// <inheritdoc /> public override async Task SetMemberAsync(TContainingType obj, IWireStreamReaderStrategyAsync source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } #if NET35 throw new NotImplementedException(); #else MemberSetter.Setter(obj, (TMemberType)await TypeSerializer.ReadAsync(source).ConfigureAwait(false)); #endif }
private void WriteCollectionSizeToField(TContainingType obj) { //We must first access the collection to get the size and then write it into the field //before we try to truly serialize it ICollection enumerable = CollectionGetter.Getter(obj) as ICollection; if (enumerable == null) { throw new InvalidOperationException($"Tried to read the size of collection in Type: {typeof(TContainingType).Name} but did not implement {nameof(ICollection)}."); } MemberSetter.Setter(obj, GenericMath.Convert <int, TSizeType>(enumerable.Count)); }
public override void SetMember(TContainingType obj, [NotNull] IWireStreamReaderStrategy source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } try { MemberSetter.Setter(obj, (TMemberType)TypeSerializer.Read(source)); } catch (Exception e) { throw new InvalidOperationException($"Failed to set member {MemberInformation.Name} on Type: {MemberInformation.DeclaringType} for Type: {obj.GetType().Name} Exception: {e.Message}.", e); } }