コード例 #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);
            }
        }
コード例 #2
0
        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";
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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");
        }
コード例 #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);
    }
コード例 #6
0
ファイル: Client.cs プロジェクト: BackupTheBerlios/boxerp-svn
        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");
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: Client.cs プロジェクト: BackupTheBerlios/boxerp-svn
        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");
        }
コード例 #9
0
        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);
        }
コード例 #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();
    }
コード例 #11
0
        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"));
        }
コード例 #12
0
ファイル: Form2.cs プロジェクト: BackupTheBerlios/boxerp-svn
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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");
        }
コード例 #18
0
        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
        }
コード例 #19
0
 public void CreateNestedBindable()
 {
     BindableWrapper<ComplexBusinessObject> bindableObj =
     new BindableWrapper<ComplexBusinessObject>(new ComplexBusinessObject());
     Assert.IsNotNull(bindableObj);
 }
コード例 #20
0
        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);
        }
コード例 #21
0
            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;
            }
コード例 #22
0
        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");
        }
コード例 #23
0
        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");
        }
コード例 #24
0
        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);
        }
コード例 #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);
        }
コード例 #26
0
        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
        }
コード例 #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);
 }
コード例 #28
0
        public void CreateBindableChangingFlags()
        {
            BindableWrapper<SimpleBusinessObject> bindableObj =
                new BindableWrapper<SimpleBusinessObject>(new SimpleBusinessObject(), true);

            Assert.IsNotNull(bindableObj);
        }
コード例 #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);
        }
コード例 #30
0
        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);
        }