public async Task TestPropertyChangedSubjectGetter()
 {
     var test2  = new TestMyPropertyChanged2Impl();
     var proxy2 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged2)test2);
     /**/
     var test1  = new TestMyPropertyChanged1Impl();
     var proxy1 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged1)test1);
     /**/
     //var temp1 = test2.PropertyChangedSubject;
     var temp2 = proxy2.PropertyChangedSubject;
     await Task.Delay(500).ConfigureAwait(false);
 }
        public async Task Test1()
        {
            var test2  = new TestMyPropertyChanged2Impl();
            var proxy2 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged2)test2);
            /**/
            var test1  = new TestMyPropertyChanged1Impl();
            var proxy1 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged1)test1);

            //var proxyProxy1 = MyNotifyPropertyChangedImpl.GetProxy(proxy1);
            using (proxy1.PropertyChangedSubject.ObserveOn(TaskPoolScheduler.Default).Subscribe(i =>
            {
                _output.WriteLine(
                    $"proxy1 {i.PropertyName} changed {(i.InnerArgs as MyNotifyPropertyChangedArgs).With(_ => _ == null ? "" : _.PropertyName)}"
                    );
            }))
            {
                _output.WriteLine("----------0");
                proxy1.P1 = 10;
                _output.WriteLine("----------1");
                proxy1.P3 = test2;
                _output.WriteLine("----------2");
                using (proxy2.PropertyChangedSubject.ObserveOn(TaskPoolScheduler.Default).Subscribe(i =>
                {
                    _output.WriteLine(string.Format("proxy2 {0} changed", i.PropertyName));
                }))
                {
                    proxy1.P3.P1 = 150;
                    _output.WriteLine("----------3");
                    proxy1.P3 = proxy2;
                    _output.WriteLine("----------4");
                    proxy2.P1 = 200;
                    _output.WriteLine("----------5");
                    proxy2.P1 = 10;
                    _output.WriteLine("----------6");
                }
            }
        }

        [Fact]
        public async Task TestSerialization()
        {
            var test2  = new TestMyPropertyChanged2Impl();
            var proxy2 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged2)test2);
            /**/
            var test1  = new TestMyPropertyChanged1Impl();
            var proxy1 = MyNotifyPropertyChangedImpl.GetProxy((ITestMyPropertyChanged1)test1);

            proxy1.P3 = proxy2;
Exemplo n.º 3
0
        public async Task Test1()
        {
            var t1 = MyNotifyPropertyChangedImpl.GetProxy(
                (ITest1) new Test1Class());

            t1.PropertyChangedSubject
            .SelectMany(
                async x =>
            {
                _output.WriteLine(
                    string.Format(
                        "{0} {1} {2}",
                        x.PropertyName,
                        x.CastedNewProperty,
                        (x.InnerArgs as MyNotifyPropertyChangedArgs).With(
                            _ => _ != null ? $"{_.PropertyName} {_.CastedNewProperty}" : ""
                            )
                        )
                    );
                await Task.Delay(10);
                return(0);
            }
                ).ObserveOn(TaskPoolScheduler.Default).Subscribe();
            _output.WriteLine("--- Prop1");
            t1.Prop1 = null;
            t1.Prop1 = "s1";
            t1.Prop1 = "s2";
            t1.Prop1 = "s2";
            /**/
            _output.WriteLine("--- Prop2");
            t1.Prop2 = new Guid();
            t1.Prop2 = Guid.NewGuid();
            t1.Prop2 = t1.Prop2;
            /**/
            _output.WriteLine("--- Prop3");
            t1.Prop3 = 0;
            t1.Prop3 = 1;
            t1.Prop3 = 1;
            /**/
            _output.WriteLine("--- Prop5 1");
            var t2Impl1 = MyNotifyPropertyChangedImpl.GetProxy(
                (ITest2) new Test2Class());

            t1.Prop5      = t2Impl1;
            t2Impl1.Prop4 = DateTime.UtcNow;
            /**/
            _output.WriteLine("--- Prop5 2");
            var t2Impl2 = MyNotifyPropertyChangedImpl.GetProxy(
                (ITest2) new Test2Class());

            t1.Prop5      = t2Impl2;
            t2Impl2.Prop4 = DateTime.MinValue;
            t2Impl2.Prop4 = DateTime.UtcNow;
            t2Impl1.Prop4 = DateTime.UtcNow;
            /**/
            _output.WriteLine("--- All Prop");
            MyNotifyPropertyChangedArgs.RaiseAllPropertiesChanged(
                t1);
            /**/
            await Task.Delay(1000).ConfigureAwait(false);
        }