コード例 #1
0
        public void BindToOneWayTestForRPSlim()
        {
            var target = new ReactivePropertySlim <string>();
            var obj    = new Poco();

            target.BindTo(obj, o => o.Name);

            obj.Name.IsNull();

            target.Value = "Hello world";
            obj.Name.Is("Hello world");
        }
コード例 #2
0
        public void BindToOnwWayConvertTestForRPSlim()
        {
            var target = new ReactivePropertySlim <int>();
            var obj    = new Poco();

            target.BindTo(
                obj,
                o => o.Name,
                convert: i => "value is " + i);

            obj.Name.Is("value is 0");

            target.Value = 1;
            obj.Name.Is("value is 1");
        }
コード例 #3
0
        public void BindToTwoWayTestForRPSlim()
        {
            var target = new ReactivePropertySlim <string>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.TwoWay,
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());
            obj.Name.IsNull();

            target.Value = "Hello world";
            obj.Name.Is("Hello world");

            obj.Name = "tanaka";
            target.Value.Is("tanaka");
        }
コード例 #4
0
        public void BindToOneWayToSourceTestForRPSlim()
        {
            var target = new ReactivePropertySlim <string>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.OneWayToSource,
                          convertBack: s =>
            {
                Debug.WriteLine(s);
                return(s + "!");
            },
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());

            obj.Name.IsNull();

            obj.Name = "Hello";
            target.Value.Is("Hello!");
        }
コード例 #5
0
        public void BindToTwoWayConvertTestForRPSlim()
        {
            var target = new ReactivePropertySlim <int>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.TwoWay,
                          convert: i => "value is " + i,
                          convertBack: s =>
            {
                Debug.WriteLine(s);
                return(int.Parse(s, NumberStyles.Integer));
            },
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());

            obj.Name.Is("value is 0");

            target.Value = 1;
            obj.Name.Is("value is 1");

            obj.Name = "3";
            target.Value.Is(3);
        }