private static async Task<object> ReadFieldValue(this FieldsStream stream, FieldInfo field, CancellationToken cancellationToken) { if (field.ShouldSerializeAsEnumerable()) { return await stream.ReadEnumerable(field.FieldType.GetGenericArguments().Single(), cancellationToken); } if (field.ShouldSerializeAsBool()) { return await stream.ReadBool(cancellationToken); } if (field.ShouldSerializeAsDateTime()) { return await stream.ReadDateTime(cancellationToken); } if (field.ShouldSerializeAsEnum()) { return await stream.ReadEnum(field.FieldType, cancellationToken); } return await stream.ReadPrimitive(field.FieldType, cancellationToken); }