public DataBinder(Gtk.Bin container, IBindableWrapper bindable)
 {
     _container = container;
     _bindable = bindable;
 }
        public void BindObject(IBindableWrapper bObject, string path, string widgetProperty, BindingOptions options)
        {
            _widgetBindingProperty = widgetProperty;
            _bindableObject = bObject;
            _bindingOptions = options;
            _bindableObject.PropertyChanged += OnPropertyChanged;

            string[] pathArray = path.Split('.');
            _boPropertyName = pathArray[pathArray.Length -1]; // the last element of the path is the property
            // now get the object whose property we've got
            if (pathArray.Length == 1)
            {
                _propertyOwner = bObject;
            }
            else
            {
                // the first element of the path have to be a property of the bObject
                int i = 0;
                PropertyInfo prop = bObject.GetType().GetProperty(pathArray[0]);
                _propertyOwner = prop.GetValue(bObject, null);
                while (pathArray.Length -2 > i)
                {
                    i++;
                    prop = _propertyOwner.GetType().GetProperty(pathArray[i]);
                    _propertyOwner = prop.GetValue(_propertyOwner, null); // try this with indexed properties!
                    _boBindingProperty = _propertyOwner.GetType().GetProperty(_boPropertyName);
                }
            }
            Logger.GetInstance().WriteLine("Property owner= " + _propertyOwner);
            Logger.GetInstance().WriteLine("bo binding property = " + _boBindingProperty.Name);
            // read the value of the property for the first time
            OnPropertyChanged(this, new PropertyChangedEventArgs(_boPropertyName));
        }
Example #3
0
 public void BindObject(IBindableWrapper wrapper, object owner, string path, string widgetProperty, BindingOptions options)
 {
     _widgetCore.BindObject(wrapper, owner, path, widgetProperty, options);
 }
        public void BindObject(IBindableWrapper bObject, object propertyOwner, 
		                       string bindingProperty, string widgetProperty, BindingOptions options)
        {
            _widgetBindingProperty = widgetProperty;
            _bindableObject = bObject;
            _propertyOwner = propertyOwner;
            _boBindingProperty = propertyOwner.GetType().GetProperty(bindingProperty);
            _boPropertyName = bindingProperty;
            if (_boBindingProperty == null)
            {
                throw new NullReferenceException("Error binding object. Property " + bindingProperty + " doesn't exist");
            }
            Logger.GetInstance().WriteLine("Binding Object property:" + _boBindingProperty.Name);
            _bindableObject.PropertyChanged += OnPropertyChanged;
            _bindingOptions = options;
        }