Repository navigation
Expand file tree
/
Copy pathWhenChangingExamples.cs
More file actions
1025 lines (824 loc) · 36.6 KB
/
Copy pathWhenChangingExamples.cs
File metadata and controls
1025 lines (824 loc) · 36.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) ReactiveUI and Contributors. All rights reserved.
// ReactiveUI and Contributors licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using System.Globalization;
using ReactiveUI.Binding.Documentation.Banking;
using ReactiveUI.Binding.Documentation.GitHub;
using ReactiveUI.Binding.Documentation.Todo;
using ReactiveUI.Primitives;
namespace ReactiveUI.Binding.Documentation.Observing;
/// <summary>
/// Shows every <c>WhenChanging</c> overload, from one observed property to sixteen, each with and without a value
/// selector. <c>WhenChanging</c> delivers the current values when you subscribe. It delivers them again just before each
/// change, so the values are the ones the change is about to replace.
/// </summary>
public static class WhenChangingExamples
{
/// <summary>The title of the registration task.</summary>
private const string RegistrationTitle = "Renew car registration";
/// <summary>The title the registration task is renamed to.</summary>
private const string RenamedTitle = "Renew car registration online";
/// <summary>The notes of the registration task.</summary>
private const string RegistrationNotes = "Bring the insurance certificate";
/// <summary>The label of an errand.</summary>
private const string ErrandsTag = "errands";
/// <summary>The label of a car task.</summary>
private const string CarTag = "car";
/// <summary>The label of an urgent task.</summary>
private const string UrgentTag = "urgent";
/// <summary>The status text of a finished task.</summary>
private const string DoneText = "done";
/// <summary>The status text of an open task.</summary>
private const string OpenText = "open";
/// <summary>The format of a day in a headline.</summary>
private const string IsoDay = "yyyy-MM-dd";
/// <summary>The number of the checkout issue.</summary>
private const int CheckoutNumber = 101;
/// <summary>The title of the checkout issue.</summary>
private const string CheckoutTitle = "Checkout button unresponsive on Safari";
/// <summary>The account name of the person the issue is assigned to.</summary>
private const string PriyaLogin = "priya-nair";
/// <summary>The display name of the person the issue is assigned to.</summary>
private const string PriyaName = "Priya Nair";
/// <summary>The account name of the person the issue is reassigned to.</summary>
private const string TomasLogin = "tomas-berg";
/// <summary>The text that stands for nobody working on an issue.</summary>
private const string Unassigned = "unassigned";
/// <summary>The label of a defect.</summary>
private const string BugLabel = "bug";
/// <summary>The label of the checkout area.</summary>
private const string CheckoutLabel = "checkout";
/// <summary>The first reply on the checkout issue.</summary>
private const string FirstReplyText = "Reproduced on Safari 17.";
/// <summary>The identifier of the account the money leaves.</summary>
private const string EverydayId = "ACC-1001";
/// <summary>The name of the account the money leaves.</summary>
private const string EverydayName = "Everyday";
/// <summary>The currency of the account the money leaves.</summary>
private const string Currency = "AUD";
/// <summary>The balance of the account the money leaves.</summary>
private const decimal EverydayBalance = 4200.50M;
/// <summary>How far below zero the account may go.</summary>
private const decimal EverydayOverdraft = 500M;
/// <summary>The money the customer can spend: the balance plus the overdraft limit.</summary>
private const decimal EverydayAvailable = 4700.50M;
/// <summary>The identifier of the payee.</summary>
private const int PayeeId = 3;
/// <summary>The identifier of the payee the customer switches to.</summary>
private const int OtherPayeeId = 4;
/// <summary>The most the customer allows in one transfer to the payee.</summary>
private const decimal PayeeLimit = 1000M;
/// <summary>The amount the customer starts with.</summary>
private const decimal RentAmount = 250M;
/// <summary>An amount above the payee's limit and below the available balance.</summary>
private const decimal AbovePayeeLimit = 1500M;
/// <summary>An amount above the available balance.</summary>
private const decimal AboveAvailable = 9000M;
/// <summary>The reference the customer starts with.</summary>
private const string RentReference = "Rent March";
/// <summary>The private note the customer starts with.</summary>
private const string MemoText = "First payment under the new lease";
/// <summary>The private note the customer changes to.</summary>
private const string MemoRevised = "Second payment under the new lease";
/// <summary>What the transfer pays for.</summary>
private const string PurposeText = "Housing";
/// <summary>What the transfer pays for once the customer changes it.</summary>
private const string PurposeRevised = "Rent";
/// <summary>The fee the bank charges for the transfer.</summary>
private const decimal TransferFee = 2.50M;
/// <summary>The text of a transfer that repeats.</summary>
private const string MonthlyText = "monthly";
/// <summary>The text of a transfer that is sent once.</summary>
private const string OnceText = "once";
/// <summary>The deadline of the registration task.</summary>
private static readonly DateOnly _registrationDue = new(2026, 3, 20);
/// <summary>The deadline the registration task moves to.</summary>
private static readonly DateOnly _movedDue = new(2026, 3, 27);
/// <summary>The labels of the registration task.</summary>
private static readonly IReadOnlyList<string> _registrationTags = [ErrandsTag, CarTag];
/// <summary>The labels of the registration task once it is urgent.</summary>
private static readonly IReadOnlyList<string> _urgentTags = [ErrandsTag, CarTag, UrgentTag];
/// <summary>The labels of the checkout issue.</summary>
private static readonly IReadOnlyList<string> _checkoutLabels = [BugLabel, CheckoutLabel];
/// <summary>The comments of a new issue.</summary>
private static readonly IReadOnlyList<IssueComment> _noComments = [];
/// <summary>When the checkout issue last changed.</summary>
private static readonly DateTimeOffset _checkoutUpdatedAt = new(2026, 3, 2, 15, 5, 0, TimeSpan.Zero);
/// <summary>When the checkout issue last changed once it has a reply.</summary>
private static readonly DateTimeOffset _repliedAt = new(2026, 3, 3, 9, 0, 0, TimeSpan.Zero);
/// <summary>The comments of the checkout issue once it has a reply.</summary>
private static readonly IReadOnlyList<IssueComment> _firstReply = [new(PriyaLogin, FirstReplyText, _repliedAt)];
/// <summary>The person the issue is assigned to.</summary>
private static readonly User _priya = new() { Login = PriyaLogin, DisplayName = PriyaName };
/// <summary>The person who reported the issue.</summary>
private static readonly User _maria = new() { Login = "maria-santos", DisplayName = "Maria Santos" };
/// <summary>The person the issue is reassigned to.</summary>
private static readonly User _tomas = new() { Login = TomasLogin, DisplayName = "Tomas Berg" };
/// <summary>The payee of the transfer.</summary>
private static readonly Payee _landlord = new(PayeeId, "Harbour Realty", "062-000 1234 5678", PayeeLimit);
/// <summary>The payee the customer switches to.</summary>
private static readonly Payee _strata = new(OtherPayeeId, "Bayside Strata", "062-000 8765 4321", null);
/// <summary>The day the transfer is sent.</summary>
private static readonly DateOnly _scheduledFor = new(2026, 4, 1);
/// <summary>The day the transfer is moved to.</summary>
private static readonly DateOnly _rescheduledFor = new(2026, 4, 8);
/// <summary>Observes the title of a to-do item; a single property delivers the value itself.</summary>
public static void ObserveTodoTitle()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item.WhenChanging(static x => x.Title).Subscribe(Console.WriteLine);
item.Title = RenamedTitle;
Console.WriteLine(item.Title);
// Output:
// Renew car registration
// Renew car registration
// Renew car registration online
}
/// <summary>Observes the title and the done flag of a to-do item together.</summary>
public static void ObserveTodoTitleAndStatus()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item.WhenChanging(static x => x.Title, static x => x.IsDone).Subscribe(static values => Console.WriteLine(values.Property2));
item.IsDone = true;
Console.WriteLine(item.IsDone);
// Output:
// False
// False
// True
}
/// <summary>Prints the status line a to-do item had before its done flag changed, with a value selector.</summary>
public static void ProjectTodoStatusLine()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.IsDone, static (title, isDone) => $"{title} ({(isDone ? DoneText : OpenText)})")
.Subscribe(Console.WriteLine);
item.IsDone = true;
// Output:
// Renew car registration (open)
// Renew car registration (open)
}
/// <summary>Observes the title, the done flag and the priority of a to-do item.</summary>
public static void ObserveTodoTitleStatusAndPriority()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.IsDone, static x => x.Priority)
.Subscribe(static values => Console.WriteLine(values.Property3));
item.Priority = TodoPriority.High;
Console.WriteLine(item.Priority);
// Output:
// Normal
// Normal
// High
}
/// <summary>Prints how urgent a to-do item was before its priority changed; a finished item is never urgent.</summary>
public static void ProjectTodoEffectivePriority()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.IsDone, static x => x.Priority, static (_, isDone, priority) => isDone ? TodoPriority.Low : priority)
.Subscribe(static priority => Console.WriteLine(priority));
item.Priority = TodoPriority.High;
// Output:
// Normal
// Normal
}
/// <summary>Observes the title, notes, done flag and deadline of a to-do item.</summary>
public static void ObserveTodoDeadline()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.Notes, static x => x.IsDone, static x => x.DueDate)
.Subscribe(static values => Console.WriteLine(values.Property4));
item.DueDate = _movedDue;
Console.WriteLine(item.DueDate);
// Output:
// 03/20/2026
// 03/20/2026
// 03/27/2026
}
/// <summary>Prints the headline a to-do item had before its deadline moved.</summary>
public static void ProjectTodoHeadline()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(
static x => x.Title,
static x => x.Notes,
static x => x.IsDone,
static x => x.DueDate,
static (title, _, isDone, due) => isDone || due is null ? title : $"{title} due {due.Value.ToString(IsoDay, CultureInfo.InvariantCulture)}")
.Subscribe(Console.WriteLine);
item.DueDate = _movedDue;
// Output:
// Renew car registration due 2026-03-20
// Renew car registration due 2026-03-20
}
/// <summary>Observes the title, notes, done flag, deadline and priority of a to-do item.</summary>
public static void ObserveTodoWithPriority()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.Notes, static x => x.IsDone, static x => x.DueDate, static x => x.Priority)
.Subscribe(static values => Console.WriteLine(values.Property5));
item.Priority = TodoPriority.High;
Console.WriteLine(item.Priority);
// Output:
// Normal
// Normal
// High
}
/// <summary>Prints whether a high-priority item needed attention before it was finished.</summary>
public static void ProjectTodoNeedsAttention()
{
TodoItemDraft item = CreateRegistrationTask();
item.Priority = TodoPriority.High;
using IDisposable subscription = item
.WhenChanging(
static x => x.Title,
static x => x.Notes,
static x => x.IsDone,
static x => x.DueDate,
static x => x.Priority,
static (_, _, isDone, due, priority) => !isDone && due is not null && priority == TodoPriority.High)
.Subscribe(Console.WriteLine);
item.IsDone = true;
// Output:
// True
// True
}
/// <summary>Observes every editable property of a to-do item; six properties is the whole form.</summary>
public static void ObserveWholeTodo()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(static x => x.Title, static x => x.Notes, static x => x.IsDone, static x => x.DueDate, static x => x.Priority, static x => x.Tags)
.Subscribe(static values => Console.WriteLine(string.Join(", ", values.Property6)));
item.Tags = _urgentTags;
Console.WriteLine(string.Join(", ", item.Tags));
// Output:
// errands, car
// errands, car
// errands, car, urgent
}
/// <summary>Prints the title with its labels as it was before the labels changed.</summary>
public static void ProjectTodoTitleWithLabels()
{
TodoItemDraft item = CreateRegistrationTask();
using IDisposable subscription = item
.WhenChanging(
static x => x.Title,
static x => x.Notes,
static x => x.IsDone,
static x => x.DueDate,
static x => x.Priority,
static x => x.Tags,
static (title, _, _, _, _, tags) => $"{title} #{string.Join(" #", tags)}")
.Subscribe(Console.WriteLine);
item.Tags = _urgentTags;
// Output:
// Renew car registration #errands #car
// Renew car registration #errands #car
}
/// <summary>Observes seven properties of an issue.</summary>
public static void ObserveIssueSummary()
{
IssueDraft issue = CreateCheckoutIssue();
using IDisposable subscription = issue
.WhenChanging(static x => x.Number, static x => x.Title, static x => x.State, static x => x.Author, static x => x.Assignee!, static x => x.Labels, static x => x.UpdatedAt)
.Subscribe(static values => Console.WriteLine(values.Property7));
issue.UpdatedAt = _repliedAt;
Console.WriteLine(issue.UpdatedAt);
// Output:
// 03/02/2026 15:05:00 +00:00
// 03/02/2026 15:05:00 +00:00
// 03/03/2026 09:00:00 +00:00
}
/// <summary>Prints the assignment line an issue had before it was reassigned, from seven properties.</summary>
public static void ProjectIssueAssignment()
{
IssueDraft issue = CreateCheckoutIssue();
using IDisposable subscription = issue
.WhenChanging(
static x => x.Number,
static x => x.Title,
static x => x.State,
static x => x.Author,
static x => x.Assignee!,
static x => x.Labels,
static x => x.UpdatedAt,
static (number, title, _, _, assignee, _, _) => $"#{number} {title} -> {assignee?.Login ?? Unassigned}")
.Subscribe(Console.WriteLine);
issue.Assignee = _tomas;
Console.WriteLine(issue.Assignee!.Login);
// Output:
// #101 Checkout button unresponsive on Safari -> priya-nair
// #101 Checkout button unresponsive on Safari -> priya-nair
// tomas-berg
}
/// <summary>Observes eight properties of an issue.</summary>
public static void ObserveIssueWithComments()
{
IssueDraft issue = CreateCheckoutIssue();
using IDisposable subscription = issue
.WhenChanging(
static x => x.Number,
static x => x.Title,
static x => x.State,
static x => x.Author,
static x => x.Assignee!,
static x => x.Labels,
static x => x.UpdatedAt,
static x => x.Comments)
.Subscribe(static values => Console.WriteLine(values.Property8.Count));
issue.Comments = _firstReply;
Console.WriteLine(issue.Comments.Count);
// Output:
// 0
// 0
// 1
}
/// <summary>Prints whether an open issue still waited for its first reply before the reply arrived.</summary>
public static void ProjectIssueAwaitsFirstReply()
{
IssueDraft issue = CreateCheckoutIssue();
using IDisposable subscription = issue
.WhenChanging(
static x => x.Number,
static x => x.Title,
static x => x.State,
static x => x.Author,
static x => x.Assignee!,
static x => x.Labels,
static x => x.UpdatedAt,
static x => x.Comments,
static (_, _, state, _, _, _, _, comments) => state == IssueState.Open && comments.Count == 0)
.Subscribe(Console.WriteLine);
issue.Comments = _firstReply;
// Output:
// True
// True
}
/// <summary>Observes a transfer and the fields of its source account, nine properties in all.</summary>
public static void ObserveTransferAndSourceAccount()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance)
.Subscribe(static values => Console.WriteLine(values.Property9));
form.AvailableBalance = EverydayBalance;
Console.WriteLine(form.AvailableBalance);
// Output:
// 4700.50
// 4700.50
// 4200.50
}
/// <summary>Prints whether the account could cover the amount before the amount changed.</summary>
public static void ProjectTransferIsAffordable()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static (amount, _, _, _, _, _, _, _, available) => amount <= available)
.Subscribe(Console.WriteLine);
form.Amount = AboveAvailable;
// Output:
// True
// True
}
/// <summary>Adds the payee to the transfer and its source account fields, ten properties in all.</summary>
public static void ObserveTransferWithPayee()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!)
.Subscribe(static values => Console.WriteLine(values.Property10?.Name));
form.Payee = _strata;
Console.WriteLine(form.Payee.Name);
// Output:
// Harbour Realty
// Harbour Realty
// Bayside Strata
}
/// <summary>Prints whether the amount fitted the account and the payee's limit before the amount changed.</summary>
public static void ProjectTransferWithinPayeeLimit()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static (amount, _, _, _, _, _, _, _, available, payee) =>
payee is not null && amount <= available && (payee.TransferLimit is not { } limit || amount <= limit))
.Subscribe(Console.WriteLine);
form.Amount = AbovePayeeLimit;
// Output:
// True
// True
}
/// <summary>Adds the day the transfer is sent, eleven properties in all.</summary>
public static void ObserveTransferSchedule()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor)
.Subscribe(static values => Console.WriteLine(values.Property11));
form.ScheduledFor = _rescheduledFor;
Console.WriteLine(form.ScheduledFor);
// Output:
// 04/01/2026
// 04/01/2026
// 04/08/2026
}
/// <summary>Prints the statement line the transfer had before it was rescheduled.</summary>
public static void ProjectTransferStatementLine()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static (_, reference, _, _, _, _, _, _, _, _, scheduledFor) => $"{reference} on {scheduledFor.ToString(IsoDay, CultureInfo.InvariantCulture)}")
.Subscribe(Console.WriteLine);
form.ScheduledFor = _rescheduledFor;
// Output:
// Rent March on 2026-04-01
// Rent March on 2026-04-01
}
/// <summary>Adds whether the transfer repeats, twelve properties in all.</summary>
public static void ObserveTransferRecurrence()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring)
.Subscribe(static values => Console.WriteLine(values.Property12));
form.IsRecurring = false;
Console.WriteLine(form.IsRecurring);
// Output:
// True
// True
// False
}
/// <summary>Prints how the transfer was described before it stopped repeating.</summary>
public static void ProjectTransferRecurrenceLabel()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static (_, reference, _, _, _, _, _, _, _, _, _, isRecurring) => $"{reference} ({(isRecurring ? MonthlyText : OnceText)})")
.Subscribe(Console.WriteLine);
form.IsRecurring = false;
// Output:
// Rent March (monthly)
// Rent March (monthly)
}
/// <summary>Adds whether the payee is told, thirteen properties in all.</summary>
public static void ObserveTransferNotification()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee)
.Subscribe(static values => Console.WriteLine(values.Property13));
form.NotifyPayee = false;
Console.WriteLine(form.NotifyPayee);
// Output:
// True
// True
// False
}
/// <summary>Prints whether the payee was going to be told before the customer switched the notice off.</summary>
public static void ProjectTransferNotifiesPayee()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static (_, _, _, _, _, _, _, _, _, payee, _, _, notifyPayee) => notifyPayee && payee is not null)
.Subscribe(Console.WriteLine);
form.NotifyPayee = false;
// Output:
// True
// True
}
/// <summary>Adds the private note, fourteen properties in all.</summary>
public static void ObserveTransferMemo()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo)
.Subscribe(static values => Console.WriteLine(values.Property14));
form.Memo = MemoRevised;
Console.WriteLine(form.Memo);
// Output:
// First payment under the new lease
// First payment under the new lease
// Second payment under the new lease
}
/// <summary>Prints the note the customer was about to replace, or the reference when there was none.</summary>
public static void ProjectTransferNote()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo,
static (_, reference, _, _, _, _, _, _, _, _, _, _, _, memo) => memo.Length > 0 ? memo : reference)
.Subscribe(Console.WriteLine);
form.Memo = MemoRevised;
// Output:
// First payment under the new lease
// First payment under the new lease
}
/// <summary>Adds what the transfer pays for, fifteen properties in all.</summary>
public static void ObserveTransferPurpose()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo,
static x => x.Purpose)
.Subscribe(static values => Console.WriteLine(values.Property15));
form.Purpose = PurposeRevised;
Console.WriteLine(form.Purpose);
// Output:
// Housing
// Housing
// Rent
}
/// <summary>Prints the purpose and reference the transfer had before the purpose changed.</summary>
public static void ProjectTransferPurposeLine()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo,
static x => x.Purpose,
static (_, reference, _, _, _, _, _, _, _, _, _, _, _, _, purpose) => $"{purpose}: {reference}")
.Subscribe(Console.WriteLine);
form.Purpose = PurposeRevised;
// Output:
// Housing: Rent March
// Housing: Rent March
}
/// <summary>Observes sixteen properties of the transfer screen, the most one call accepts.</summary>
public static void ObserveTransferFee()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo,
static x => x.Purpose,
static x => x.Fee)
.Subscribe(static values => Console.WriteLine(values.Property16));
form.Fee = 0M;
Console.WriteLine(form.Fee);
// Output:
// 2.50
// 2.50
// 0
}
/// <summary>Prints whether the amount and fee fitted the account before the fee changed.</summary>
public static void ProjectTransferTotalIsAffordable()
{
TransferForm form = CreateTransferForm();
using IDisposable subscription = form
.WhenChanging(
static x => x.Amount,
static x => x.Reference,
static x => x.SourceId,
static x => x.SourceName,
static x => x.SourceKind,
static x => x.Currency,
static x => x.Balance,
static x => x.OverdraftLimit,
static x => x.AvailableBalance,
static x => x.Payee!,
static x => x.ScheduledFor,
static x => x.IsRecurring,
static x => x.NotifyPayee,
static x => x.Memo,
static x => x.Purpose,
static x => x.Fee,
static (amount, _, _, _, _, _, _, _, available, _, _, _, _, _, _, fee) => amount + fee <= available)
.Subscribe(Console.WriteLine);
form.Fee = AboveAvailable;
// Output:
// True
// True
}
/// <summary>Creates the to-do item form the examples observe.</summary>
/// <returns>An open, unfinished item.</returns>
private static TodoItemDraft CreateRegistrationTask() => new()
{
Title = RegistrationTitle,
Notes = RegistrationNotes,
DueDate = _registrationDue,
Priority = TodoPriority.Normal,
Tags = _registrationTags,
};
/// <summary>Creates the issue form the examples observe.</summary>
/// <returns>An open issue reported by Maria and assigned to Priya.</returns>
private static IssueDraft CreateCheckoutIssue() => new()
{
Number = CheckoutNumber,
Title = CheckoutTitle,
State = IssueState.Open,
Author = _maria,
Assignee = _priya,
Labels = _checkoutLabels,
Comments = _noComments,