Exemplo n.º 1
0
        public Window1()
        {
            InitializeComponent();

            try
            {
                _proxy2 = new Proxy2();
                _proxy2.Name = "test";

                SampleBObj businessObject = new SampleBObj();
                businessObject.Name = "test";
                businessObject.Description = "description";
                businessObject.Age = 10;

                _bindable = new BindableWrapper<SampleBObj>(businessObject);

                if (_useRealProxy)
                {
                    DataContext = _proxy2;
                }
                else // using dynamic proxy
                {
                    DataContext = _bindable.Data.BusinessObj;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        public void UndoNestedChanges()
        {
            BindableWrapper<ComplexBusinessObject> bindableObj =
            new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());

            SimpleBusinessObject sbo1 = new SimpleBusinessObject();
            sbo1.Name = "sbo1";
            SimpleBusinessObject sbo2 = new SimpleBusinessObject();
            sbo2.Name = "sbo2";

            bindableObj.Data.BusinessObj.NestedObject = sbo1;
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo1.Name);

            bindableObj.Data.BusinessObj.NestedObject = sbo2;
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo2.Name);

            bindableObj.Undo();

            // As the nested object is not intercepted undo does not have any effect
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo2.Name);

            // the nested object is not IBindableWrapper so changes on its internal properties are not intercepted
            bindableObj.Data.BusinessObj.NestedObject.Name = "whatever";
            bindableObj.Data.BusinessObj.NestedObject.Name = "somethingelse";
        }
        public void ChangeNestedBindable()
        {
            BindableWrapper<ComplexBusinessObject> bindableObj =
            new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());
            bindableObj.Data.BusinessObj.SomeFlag = true;
            bindableObj.Data.BusinessObj.NestedObject = new SimpleBusinessObject();

            Assert.IsNotNull(bindableObj.Data.BusinessObj.NestedObject);
        }
        public void ChangeBindableSGO()
        {
            BindableWrapper<SimpleGenericObject<string>> bindableObj =
            new BindableWrapper<SimpleGenericObject<string>>(new SimpleGenericObject<string>());

            bindableObj.Data.BusinessObj.Code = "code";
            bindableObj.Data.BusinessObj.GenericArray = new string[] { "test1", "test2"};
            Assert.AreEqual(bindableObj.Data.BusinessObj.GenericArray[0], "test1");
        }
Exemplo n.º 5
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        _bindable = new BindableWrapper<SampleBObj>(new SampleBObj());
        vbox2.PackEnd(_age, true, true, 0);

        _age.BindObject(_bindable, _bindable.Data.BusinessObj, "Age", BindingOptions.TwoWay);
    }
Exemplo n.º 6
0
        private static void SendBindableWrapperComplexObject(BindableObjectsDeserializer bod)
        {
            BindableWrapper<ComplexBusinessObject> bindableObj =
            new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());
            bindableObj.Data.BusinessObj.SomeFlag = true;
            bindableObj.Data.BusinessObj.NestedObject = new SimpleBusinessObject();
            bindableObj.Data.BusinessObj.NestedObject.Name = "asdf";
            bod.ReadBindableComplexObject(bindableObj);

            Console.WriteLine("Server called");
        }
        public void ChangeBindableSIC()
        {
            BindableWrapper<SimpleIndexedClass> bindableObj =
            new BindableWrapper<SimpleIndexedClass>(new SimpleIndexedClass());

            bindableObj.Data.BusinessObj.Code = "code";
            bindableObj.Data.BusinessObj["test"] = 1;
            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 1);
            bindableObj.Data.BusinessObj["test"] = 2;
            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 2);
        }
Exemplo n.º 8
0
        private static void SendBindableWrapperSBO(BindableObjectsDeserializer bod)
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
            new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject());
            bindableObj.Data.BusinessObj.Name = "asdf";
            bindableObj.Data.BusinessObj.Description = "asdfsdf";
            bindableObj.Data.BusinessObj.Age = 25;

            bod.ReadBindableObject(bindableObj);

            Console.WriteLine("Server called");
        }
        public void ChangeBindableSBO()
        {
            System.Diagnostics.Debug.WriteLine("asdfasdfsdf");
            BindableWrapper<SimpleBusinessObject> bindableObj =
            new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject());
            bindableObj.Data.BusinessObj.Name = "asdf";
            bindableObj.Data.BusinessObj.Description = "asdfsdf";
            bindableObj.Data.BusinessObj.Age = 25;

            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "asdf");
            Assert.AreEqual(bindableObj.Data.BusinessObj.Age, 25);
        }
Exemplo n.º 10
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();
        _user = new User();

        _bindable = new BindableWrapper<User>(_user);
        _bindable.Data.BusinessObj.Username = "******";

        DataBinder binder = new DataBinder(this, _bindable);
        binder.Bind();
    }
        public void ChangeBindableSOCP()
        {
            BindableWrapper<SimpleObjectComplexProperties> bindableObj =
            new BindableWrapper<SimpleObjectComplexProperties>(new SimpleObjectComplexProperties());
            bindableObj.Data.BusinessObj.Code = "asdf";
            bindableObj.Data.BusinessObj.Ages[2] = 70;
            bindableObj.Data.BusinessObj.Names = new System.Collections.Generic.List<string>();
            bindableObj.Data.BusinessObj.Names.Add("test");

            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "asdf");
            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[2], 70);
            Assert.IsTrue(bindableObj.Data.BusinessObj.Names.Contains("test"));
        }
Exemplo n.º 12
0
        public Form2()
        {
            InitializeComponent();
            SampleBObj businessObject = new SampleBObj();
            businessObject.Name = "test2";
            businessObject.Description = "test2";
            businessObject.Age = 44;

            _bindable = new BindableWrapper<SampleBObj>(businessObject);

            // bind the object properties to the UI widgets
            _name.DataBindings.Add("Text", _bindable.Data.BusinessObjBinding, "Name", false, DataSourceUpdateMode.OnPropertyChanged);
            _description.DataBindings.Add("Text", _bindable.Data.BusinessObjBinding, "Description", false, DataSourceUpdateMode.OnPropertyChanged);
            _age.DataBindings.Add("Text", _bindable.Data.BusinessObjBinding, "Age", false, DataSourceUpdateMode.OnPropertyChanged);
        }
        public void SerializationTest()
        {
            BindableWrapper<ComplexBusinessObject> bindableObj =
            new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());
            bindableObj.Data.BusinessObj.SomeFlag = true;
            bindableObj.Data.BusinessObj.NestedObject = new SimpleBusinessObject();

            MemoryStream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, bindableObj);
            stream.Position = 0;

            object deserializedObject = formatter.Deserialize(stream);
            Assert.IsNotNull(deserializedObject);
            BindableWrapper<ComplexBusinessObject> deserializedBindable = (BindableWrapper<ComplexBusinessObject>)deserializedObject;

            Assert.IsNotNull(deserializedBindable);
            Assert.IsTrue(deserializedBindable.Data.BusinessObj.SomeFlag);
            Assert.IsNotNull(deserializedBindable.Data.BusinessObj.NestedObject);
        }
        public void SerializationWithEventSubscriberTest()
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
            new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject());

            AnySubscriber subscriber = new AnySubscriber();
            bindableObj.PropertyChanged += subscriber.OnPropertyChanged;

            Assert.IsTrue(bindableObj.HasSubscribers);

            MemoryStream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, bindableObj);
            stream.Position = 0;

            object deserializedObject = formatter.Deserialize(stream);
            Assert.IsNotNull(deserializedObject);
            BindableWrapper<SimpleBusinessObject> deserializedBindable = (BindableWrapper<SimpleBusinessObject>)deserializedObject;

            Assert.IsNotNull(deserializedBindable);

            Assert.IsFalse(deserializedBindable.HasSubscribers);
        }
        public void UndoChangesSIC()
        {
            BindableWrapper<SimpleIndexedClass> bindableObj =
            new BindableWrapper<SimpleIndexedClass>(new SimpleIndexedClass());

            bindableObj.Data.BusinessObj["test"] = 1;

            bindableObj.Data.BusinessObj["test"] = 2;

            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 2);

            bindableObj.Undo();

            // changes in the objects within the collection are not intercepted so no undo changes
            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 2);
        }
        public void UndoRedoNestedChanges()
        {
            BindableWrapper<ComplexBusinessObject> bindableObj =
            new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());

            SimpleBusinessObject sbo1 = new SimpleBusinessObject();
            sbo1.Name = "sbo1";
            SimpleBusinessObject sbo2 = new SimpleBusinessObject();
            sbo2.Name = "sbo2";

            bindableObj.Data.BusinessObj.NestedObject = sbo1;
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo1.Name);

            bindableObj.Data.BusinessObj.NestedObject = sbo2;
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo2.Name);

            bindableObj.Undo();

            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo2.Name);

            bindableObj.Redo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.NestedObject.Name, sbo2.Name);
        }
        public void UndoRedoChangesSBO()
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
            new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject());
            bindableObj.Data.BusinessObj.Name = "asdf";
            bindableObj.Data.BusinessObj.Description = "asdfsdf";
            bindableObj.Data.BusinessObj.Age = 25;

            bindableObj.Data.BusinessObj.Name = "qwerty";
            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "qwerty");

            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "asdf");

            bindableObj.Redo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "qwerty");
        }
        public void UndoChangesSBONoInterception()
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
            new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject(), true);
            bindableObj.Data.BusinessObj.Name = "asdf";
            bindableObj.Data.BusinessObj.Description = "asdfsdf";
            bindableObj.Data.BusinessObj.Age = 25;

            bindableObj.Data.BusinessObj.Name = "qwerty";
            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "qwerty");

            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Name, "qwerty"); // no changes, no interception
        }
 public void CreateNestedBindable()
 {
     BindableWrapper<ComplexBusinessObject> bindableObj =
     new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());
     Assert.IsNotNull(bindableObj);
 }
        public void UndoChangesSOVT()
        {
            BindableWrapper<SimpleObjectValueTypes> bindableObj =
            new BindableWrapper<SimpleObjectValueTypes>(new SimpleObjectValueTypes());

            bindableObj.Data.BusinessObj.Boolean = false;
            bindableObj.Data.BusinessObj.Char = 'a';
            bindableObj.Data.BusinessObj.Double = 100;
            bindableObj.Data.BusinessObj.Float = 100;
            bindableObj.Data.BusinessObj.Enum = SimpleEnum.line1;
            bindableObj.Data.BusinessObj.Integer = 5;
            bindableObj.Data.BusinessObj.Struct = new SimpleStruct();

            Assert.AreEqual(bindableObj.Data.BusinessObj.Boolean, false);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Char, 'a');
            Assert.AreEqual(bindableObj.Data.BusinessObj.Double, 100);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Float, 100);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Enum, SimpleEnum.line1);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Integer, 5);
            //Assert.AreEqual(bindableObj.Data.BusinessObj.Struct._int1, 1);

            bindableObj.Data.BusinessObj.Boolean = true;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Boolean, false);

            bindableObj.Data.BusinessObj.Char = 'b';
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Char, 'a');

            bindableObj.Data.BusinessObj.Double = 200;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Double, 100);

            bindableObj.Data.BusinessObj.Float = 200;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Float, 100);

            bindableObj.Data.BusinessObj.Enum = SimpleEnum.line2;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Enum, SimpleEnum.line1);

            bindableObj.Data.BusinessObj.Integer = 7;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Integer, 5);
        }
            public TestForm(Person person)
            {
                this.person = person;
                name.Name = "name";
                _name.Name = "_name";
                inputbox.Name = "inputbox";
                Control holder = flowPanel;
                Label lNewLabel = new Label() { Text = "name" };
                holder.Controls.Add(lNewLabel);
                holder.Controls.Add(name);
                holder.Controls.Add(new Label(){Text = "_name"});
                holder.Controls.Add(_name);
                holder.Controls.Add(new Label() { Text = "input"});
                holder.Controls.Add(inputbox);
                flowPanel.Dock = DockStyle.Fill;
                Controls.Add(flowPanel);
                BindableWrapper<Person> _bindable = new BindableWrapper<Person>(person);
                DataBinder<Person, Form> dataBinder  = new DataBinder<Person, Form>( _bindable, this);
                dataBinder.BindWithReflection();

                inputbox.TextChanged += (sender, ea) => person.Name = inputbox.Text;

                //inputbox.TextChanged += (sender, ea) => name.Text = inputbox.Text;
            }
        public void UndoChangesSGO()
        {
            BindableWrapper<SimpleGenericObject<string>> bindableObj =
            new BindableWrapper<SimpleGenericObject<string>>(new SimpleGenericObject<string>());

            bindableObj.Data.BusinessObj.GenericArray = new string[] { "test1", "test2" };
            bindableObj.Data.BusinessObj.GenericArray[0] = "test3";
            bindableObj.Data.BusinessObj.Code = "code1";
            bindableObj.Data.BusinessObj.Code = "code2";
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "code2");
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "code1");
            // changes in array elements are not intercepted
            Assert.AreEqual(bindableObj.Data.BusinessObj.GenericArray[0], "test3");
        }
        public void UndoRedoChangesSIC()
        {
            BindableWrapper<SimpleIndexedClass> bindableObj =
            new BindableWrapper<SimpleIndexedClass>(new SimpleIndexedClass());

            bindableObj.Data.BusinessObj["test"] = 1;

            bindableObj.Data.BusinessObj["test"] = 2;

            bindableObj.Data.BusinessObj.Code = "asdf";
            bindableObj.Data.BusinessObj.Code = "12345";

            bindableObj.Undo();

            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 2);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "asdf");

            bindableObj.Redo();

            Assert.AreEqual(bindableObj.Data.BusinessObj["test"], 2);
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "12345");
        }
        public void UndoRedoChangesSOBCP()
        {
            BindableWrapper<SimpleObjectComplexProperties> bindableObj =
            new BindableWrapper<SimpleObjectComplexProperties>(new SimpleObjectComplexProperties());
            bindableObj.Data.BusinessObj.Code = "asdf";
            bindableObj.Data.BusinessObj.Ages[1]  = 0;
            bindableObj.Data.BusinessObj.Names = new System.Collections.Generic.List<string>();
            bindableObj.Data.BusinessObj.Names.Add("test");

            bindableObj.Data.BusinessObj.Ages[1] = 80;
            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[1], 80);

            bindableObj.Undo();

            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[1], 80);

            bindableObj.Redo();

            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[1], 80);
        }
Exemplo n.º 25
0
        private void addUsers()
        {
            User user1 = new User();
            user1.Username = "******";
            user1.Desk = 540;
            user1.Email = "*****@*****.**";
            user1.Password = "******";

            User user2 = new User();
            user2.Username = "******";
            user2.Desk = 143;
            user2.Email = "*****@*****.**";
            user2.Password = "******";
            bindableUser2 = new BindableWrapper<User>(user2);
            _combo.Items.Add(user1);
            _combo.Items.Add(bindableUser2.Data.BusinessObj);
        }
        public void UndoChangesSOCP()
        {
            BindableWrapper<SimpleObjectComplexProperties> bindableObj =
            new BindableWrapper<SimpleObjectComplexProperties>(new SimpleObjectComplexProperties());
            bindableObj.Data.BusinessObj.Code = "asdf";
            bindableObj.Data.BusinessObj.Ages[3] = 777;
            bindableObj.Data.BusinessObj.Names = new System.Collections.Generic.List<string>();
            bindableObj.Data.BusinessObj.Names.Add("test");

            bindableObj.Data.BusinessObj.Code = "change";
            bindableObj.Data.BusinessObj.Ages[3] = 22;
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "change");
            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[3], 22);
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Code, "asdf");
            // array is not intercepted so it does not change
            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[3], 22);
            Assert.IsTrue(bindableObj.Data.BusinessObj.Names.Contains("test")); // no undo for this as it is not intercepted

            bindableObj.Data.BusinessObj.Ages[3] = 22;
            bindableObj.Data.BusinessObj.Ages[3] = 25;
            bindableObj.Undo();
            Assert.AreEqual(bindableObj.Data.BusinessObj.Ages[3], 25); // not intercepted so nothing to undo
        }
Exemplo n.º 27
0
 private void tryDataBinding()
 {
     createGroup();
     _bindableGroup = new BindableWrapper<GroupAwareUsers>(_group);
     Console.WriteLine("users:" + _bindableGroup.Data.BusinessObj.Users.Count);
     _listView.BindObject(_bindableGroup, "Data.BusinessObj.Users", "BoundItems", BindingOptions.TwoWay);
 }
        public void CreateBindableChangingFlags()
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
                new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject(), true);

            Assert.IsNotNull(bindableObj);
        }
Exemplo n.º 29
0
        private void addUsers()
        {
            User user1 = new User();
            user1.Username = "******";
            user1.Desk = 540;
            user1.Email = "*****@*****.**";
            user1.Password = "******";

            User user2 = new User();
            user2.Username = "******";
            user2.Desk = 143;
            user2.Email = "*****@*****.**";
            user2.Password = "******";
            bindableUser2 = new BindableWrapper<User>(user2);
            Logger.GetInstance().WriteLine("gonna insert:" + _dataGrid.Items);
            _dataGrid.Items.Add(user1);
            _dataGrid.Items.Add(bindableUser2.Data.BusinessObj);
        }
        public void SerializationSOCPTest()
        {
            BindableWrapper<SimpleObjectComplexProperties> bindableObj =
            new BindableWrapper<SimpleObjectComplexProperties>(new SimpleObjectComplexProperties());

            MemoryStream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, bindableObj.Data.BusinessObj);
            stream.Position = 0;

            object deserializedObject = formatter.Deserialize(stream);
            Assert.IsNotNull(deserializedObject);
            SimpleObjectComplexProperties deserializedBindable = (SimpleObjectComplexProperties)deserializedObject;

            Assert.IsNotNull(deserializedBindable);
        }