public RelatedCurrencyManager(BindingManagerBase parent, PropertyDescriptor prop_desc)
            : base(prop_desc.GetValue (parent.Current))
        {
            this.parent = parent;
            this.prop_desc = prop_desc;

            parent.PositionChanged += new EventHandler (parent_PositionChanged);
        }
        public RelatedPropertyManager(BindingManagerBase parent, string property_name)
        {
            this.parent = parent;
            this.property_name = property_name;

            if (parent.Position != -1)
                SetDataSource (parent.Current);
            parent.PositionChanged += new EventHandler (parent_PositionChanged);
        }
Esempio n. 3
0
        public RelatedPropertyManager(BindingManagerBase parent, string property_name)
        {
            this.parent        = parent;
            this.property_name = property_name;

            if (parent.Position != -1)
            {
                SetDataSource(parent.Current);
            }
            parent.PositionChanged += new EventHandler(parent_PositionChanged);
        }
Esempio n. 4
0
        internal void Check()
        {
            if (control == null || control.BindingContext == null)
            {
                return;
            }

            if (manager == null)
            {
                manager = control.BindingContext [data_source, binding_member_info.BindingPath];

                if (manager.Position > -1 && binding_member_info.BindingField != String.Empty &&
                    TypeDescriptor.GetProperties(manager.Current).Find(binding_member_info.BindingField, true) == null)
                {
                    throw new ArgumentException("Cannot bind to property '" + binding_member_info.BindingField + "' on DataSource.",
                                                "dataMember");
                }

                manager.AddBinding(this);
                manager.PositionChanged += new EventHandler(PositionChangedHandler);

                if (manager is PropertyManager)                   // Match .net, which only watchs simple objects
                {
                    EventDescriptor prop_changed_event = GetPropertyChangedEvent(manager.Current, binding_member_info.BindingField);
                    if (prop_changed_event != null)
                    {
                        prop_changed_event.AddEventHandler(manager.Current, new EventHandler(SourcePropertyChangedHandler));
                    }
                    else if (manager.Current is INotifyPropertyChanged)
                    {
                        INotifyPropertyChanged notified = manager.Current as INotifyPropertyChanged;
                        notified.PropertyChanged += new PropertyChangedEventHandler(NotifiedPropertyChangedHandler);
                    }
                }
                else if (manager is CurrencyManager)
                {
                    manager.CurrentItemChanged += new EventHandler(CurrentItemChangedHandler);
                }
            }

            if (manager.Position == -1)
            {
                return;
            }

            if (!checked_isnull)
            {
                is_null_desc   = TypeDescriptor.GetProperties(manager.Current).Find(property_name + "IsNull", false);
                checked_isnull = true;
            }

            PushData(false, true);
        }
Esempio n. 5
0
        protected virtual void AddCore(object dataSource, BindingManagerBase listManager)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }
            if (listManager == null)
            {
                throw new ArgumentNullException("listManager");
            }

            HashKey key = new HashKey(dataSource, String.Empty);

            managers [key] = listManager;
        }
Esempio n. 6
0
        public BindingManagerBase this [object dataSource, string dataMember] {
            get {
                if (dataSource == null)
                {
                    throw new ArgumentNullException("dataSource");
                }
                if (dataMember == null)
                {
                    dataMember = String.Empty;
                }

                ICurrencyManagerProvider cm_provider = dataSource as ICurrencyManagerProvider;
                if (cm_provider != null)
                {
                    if (dataMember.Length == 0)
                    {
                        return(cm_provider.CurrencyManager);
                    }

                    return(cm_provider.GetRelatedCurrencyManager(dataMember));
                }

                HashKey            key = new HashKey(dataSource, dataMember);
                BindingManagerBase res = managers [key] as BindingManagerBase;

                if (res != null)
                {
                    return(res);
                }

                res = CreateBindingManager(dataSource, dataMember);
                if (res == null)
                {
                    return(null);
                }
                managers [key] = res;
                return(res);
            }
        }
Esempio n. 7
0
        private BindingManagerBase CreateBindingManager(object data_source, string data_member)
        {
            if (data_member == "")
            {
                if (IsListType(data_source.GetType()))
                {
                    return(new CurrencyManager(data_source));
                }
                else
                {
                    return(new PropertyManager(data_source));
                }
            }
            else
            {
                BindingMemberInfo info = new BindingMemberInfo(data_member);

                BindingManagerBase parent_manager = this[data_source, info.BindingPath];

                PropertyDescriptor pd = parent_manager == null ? null : parent_manager.GetItemProperties().Find(info.BindingField, true);

                if (pd == null)
                {
                    throw new ArgumentException(String.Format("Cannot create a child list for field {0}.", info.BindingField));
                }

                if (IsListType(pd.PropertyType))
                {
                    return(new RelatedCurrencyManager(parent_manager, pd));
                }
                else
                {
                    return(new RelatedPropertyManager(parent_manager, info.BindingField));
                }
            }
        }
Esempio n. 8
0
 protected internal void Add(object dataSource, BindingManagerBase listManager)
 {
     AddCore(dataSource, listManager);
     OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, dataSource));
 }
Esempio n. 9
0
        protected virtual void AddCore(object dataSource, BindingManagerBase listManager)
        {
            if (dataSource == null)
                throw new ArgumentNullException ("dataSource");
            if (listManager == null)
                throw new ArgumentNullException ("listManager");

            HashKey key = new HashKey (dataSource, String.Empty);
            managers [key] = listManager;
        }
Esempio n. 10
0
 protected internal void Add(object dataSource, BindingManagerBase listManager)
 {
     AddCore (dataSource, listManager);
     OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, dataSource));
 }
Esempio n. 11
0
        internal void Check()
        {
            if (control == null || control.BindingContext == null)
                return;

            if (manager == null) {
                manager = control.BindingContext [data_source, binding_member_info.BindingPath];

                if (manager.Position > -1 && binding_member_info.BindingField != String.Empty &&
                    TypeDescriptor.GetProperties (manager.Current).Find (binding_member_info.BindingField, true) == null)
                    throw new ArgumentException ("Cannot bind to property '" + binding_member_info.BindingField + "' on DataSource.",
                            "dataMember");

                manager.AddBinding (this);
                manager.PositionChanged += new EventHandler (PositionChangedHandler);

                if (manager is PropertyManager) { // Match .net, which only watchs simple objects
                    EventDescriptor prop_changed_event = GetPropertyChangedEvent (manager.Current, binding_member_info.BindingField);
                    if (prop_changed_event != null)
                        prop_changed_event.AddEventHandler (manager.Current, new EventHandler (SourcePropertyChangedHandler));
                    else if (manager.Current is INotifyPropertyChanged) {
                        INotifyPropertyChanged notified = manager.Current as INotifyPropertyChanged;
                        notified.PropertyChanged += new PropertyChangedEventHandler (NotifiedPropertyChangedHandler);
                    }
                } else if (manager is CurrencyManager) {
                    manager.CurrentItemChanged += new EventHandler (CurrentItemChangedHandler);
                }
            }

            if (manager.Position == -1)
                return;

            if (!checked_isnull) {
                is_null_desc = TypeDescriptor.GetProperties (manager.Current).Find (property_name + "IsNull", false);
                checked_isnull = true;
            }

            PushData (false, true);
        }