@@ -471,6 +471,64 @@ public class ReadAllOptions : OperationOptions {
471
471
/// Allows to customize or disable the automatic deserialization
472
472
/// </summary>
473
473
public OperationSerializationSettings ? SerializationSettings { get ; set ; }
474
+
475
+ public static ReadAllOptions Get ( ) =>
476
+ new ReadAllOptions ( ) ;
477
+
478
+ public ReadAllOptions Forwards ( ) {
479
+ Direction = Direction . Forwards ;
480
+
481
+ return this ;
482
+ }
483
+
484
+ public ReadAllOptions WithFilter ( IEventFilter filter ) {
485
+ Filter = filter ;
486
+
487
+ return this ;
488
+ }
489
+
490
+ public ReadAllOptions Backwards ( ) {
491
+ Direction = Direction . Backwards ;
492
+
493
+ return this ;
494
+ }
495
+
496
+ public ReadAllOptions From ( Position streamPosition ) {
497
+ Position = streamPosition ;
498
+
499
+ return this ;
500
+ }
501
+
502
+ public ReadAllOptions FromStart ( ) =>
503
+ From ( Position . Start ) ;
504
+
505
+ public ReadAllOptions FromEnd ( ) =>
506
+ From ( Position . End ) ;
507
+
508
+ public ReadAllOptions WithMaxCount ( long maxCount ) {
509
+ MaxCount = maxCount ;
510
+
511
+ return this ;
512
+ }
513
+
514
+ public ReadAllOptions MaxOne ( ) =>
515
+ WithMaxCount ( 1 ) ;
516
+
517
+ public ReadAllOptions First ( ) =>
518
+ FromStart ( )
519
+ . Forwards ( )
520
+ . MaxOne ( ) ;
521
+
522
+ public ReadAllOptions Last ( ) =>
523
+ FromEnd ( )
524
+ . Backwards ( )
525
+ . MaxOne ( ) ;
526
+
527
+ public ReadAllOptions DisableAutoSerialization ( ) {
528
+ SerializationSettings = OperationSerializationSettings . Disabled ;
529
+
530
+ return this ;
531
+ }
474
532
}
475
533
476
534
/// <summary>
@@ -502,9 +560,62 @@ public class ReadStreamOptions : OperationOptions {
502
560
/// Allows to customize or disable the automatic deserialization
503
561
/// </summary>
504
562
public OperationSerializationSettings ? SerializationSettings { get ; set ; }
563
+
564
+ public static ReadStreamOptions Get ( ) =>
565
+ new ReadStreamOptions ( ) ;
566
+
567
+ public ReadStreamOptions Forwards ( ) {
568
+ Direction = Direction . Forwards ;
569
+
570
+ return this ;
571
+ }
572
+
573
+ public ReadStreamOptions Backwards ( ) {
574
+ Direction = Direction . Backwards ;
575
+
576
+ return this ;
577
+ }
578
+
579
+ public ReadStreamOptions From ( StreamPosition streamPosition ) {
580
+ StreamPosition = streamPosition ;
581
+
582
+ return this ;
583
+ }
584
+
585
+ public ReadStreamOptions FromStart ( ) =>
586
+ From ( StreamPosition . Start ) ;
587
+
588
+ public ReadStreamOptions FromEnd ( ) =>
589
+ From ( StreamPosition . End ) ;
590
+
591
+ public ReadStreamOptions WithMaxCount ( long maxCount ) {
592
+ MaxCount = maxCount ;
593
+
594
+ return this ;
595
+ }
596
+
597
+ public ReadStreamOptions MaxOne ( ) =>
598
+ WithMaxCount ( 1 ) ;
599
+
600
+ public ReadStreamOptions First ( ) =>
601
+ FromStart ( )
602
+ . Forwards ( )
603
+ . MaxOne ( ) ;
604
+
605
+ public ReadStreamOptions Last ( ) =>
606
+ FromEnd ( )
607
+ . Backwards ( )
608
+ . MaxOne ( ) ;
609
+
610
+ public ReadStreamOptions DisableAutoSerialization ( ) {
611
+ SerializationSettings = OperationSerializationSettings . Disabled ;
612
+
613
+ return this ;
614
+ }
505
615
}
506
616
507
- public static class KurrentDBClientReadExtensions {
617
+ [ Obsolete ( "Those extensions may be removed in the future versions" , false ) ]
618
+ public static class ObsoleteKurrentDBClientReadExtensions {
508
619
/// <summary>
509
620
/// Asynchronously reads all events.
510
621
/// </summary>
@@ -517,6 +628,10 @@ public static class KurrentDBClientReadExtensions {
517
628
/// <param name="userCredentials">The optional <see cref="UserCredentials"/> to perform operation with.</param>
518
629
/// <param name="cancellationToken">The optional <see cref="System.Threading.CancellationToken"/>.</param>
519
630
/// <returns></returns>
631
+ [ Obsolete (
632
+ "This method may be removed in future releases. Use the overload with ReadAllOptions and get auto-serialization capabilities" ,
633
+ false
634
+ ) ]
520
635
public static KurrentDBClient . ReadAllStreamResult ReadAllAsync (
521
636
this KurrentDBClient dbClient ,
522
637
Direction direction ,
@@ -554,6 +669,10 @@ public static KurrentDBClient.ReadAllStreamResult ReadAllAsync(
554
669
/// <param name="userCredentials">The optional <see cref="UserCredentials"/> to perform operation with.</param>
555
670
/// <param name="cancellationToken">The optional <see cref="System.Threading.CancellationToken"/>.</param>
556
671
/// <returns></returns>
672
+ [ Obsolete (
673
+ "This method may be removed in future releases. Use the overload with ReadAllOptions and get auto-serialization capabilities" ,
674
+ false
675
+ ) ]
557
676
public static KurrentDBClient . ReadAllStreamResult ReadAllAsync (
558
677
this KurrentDBClient dbClient ,
559
678
Direction direction ,
@@ -598,6 +717,10 @@ public static KurrentDBClient.ReadAllStreamResult ReadAllAsync(
598
717
/// <param name="userCredentials">The optional <see cref="UserCredentials"/> to perform operation with.</param>
599
718
/// <param name="cancellationToken">The optional <see cref="System.Threading.CancellationToken"/>.</param>
600
719
/// <returns></returns>
720
+ [ Obsolete (
721
+ "This method may be removed in future releases. Use the overload with ReadStreamOptions and get auto-serialization capabilities" ,
722
+ false
723
+ ) ]
601
724
public static KurrentDBClient . ReadStreamResult ReadStreamAsync (
602
725
this KurrentDBClient dbClient ,
603
726
Direction direction ,
0 commit comments