Exemple #1
0
        static void ViolatesContract()
        {
            var observable = new MyContractViolatingRangeObservable(5, 8);

            var observer = new MyObserver <int>();

            var subscription = observable.Subscribe(observer);

            Console.WriteLine("Press any key to dispose the subscription.");
            Console.ReadKey();
            subscription.Dispose();
        }
Exemple #2
0
        static void ObserverBaseMitigatesContractViolation1()
        {
            var observable = new MyContractViolatingRangeObservable(5, 8);

            var subscription = observable.Subscribe(
                Console.WriteLine,
                ex => Console.WriteLine(ex.Message),
                () => Console.WriteLine("Completed."));

            Console.WriteLine("Press any key to dispose the subscription.");
            Console.ReadKey();
            subscription.Dispose();
        }