Esempio n. 1
0
        void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action <IEnumerable <string>, bool> itemsCalculated, Func <bool> itemsCalculating)
        {
            PropertyChangedEventHandler propertyChangedEventHandler = (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);

            if (_propertyEditor.ObjectTypeInfo.IsPersistent)
            {
                ((IObjectSpaceHolder)_propertyEditor).ObjectSpace.ObjectChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
            }
            else
            {
                var currentObject = _propertyEditor.CurrentObject as INotifyPropertyChanged;
                if (currentObject != null)
                {
                    ((INotifyPropertyChanged)_propertyEditor.CurrentObject).PropertyChanged += propertyChangedEventHandler;
                }
            }

            BuildFromDataSourceWhenCurrentObjectChanges(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, propertyChangedEventHandler);

            var b = itemsCalculating.Invoke();

            if (!b)
            {
                var boxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
                itemsCalculated.Invoke(boxItems, false);
            }
        }
Esempio n. 2
0
 void BuildFromDatasourceCore(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action<IEnumerable<string>, bool> itemsCalculated, Func<bool> itemsCalculating, string propertyName) {
     if (_propertyEditor.PropertyName != propertyName) {
         var invoke = itemsCalculating.Invoke();
         if (!invoke) {
             var comboBoxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
             itemsCalculated.Invoke(comboBoxItems, true);
         }
     }
 }
Esempio n. 3
0
        IEnumerable <string> GetComboBoxItemsCore(DataSourcePropertyAttribute dataSourcePropertyAttribute)
        {
            var objectTypeInfo = _propertyEditor.ObjectTypeInfo;

            if (_propertyEditor.MemberInfo is MemberPathInfo memberInfo)
            {
                objectTypeInfo = memberInfo.LastMember.Owner;
            }
            return((IEnumerable <string>)objectTypeInfo.FindMember(dataSourcePropertyAttribute.DataSourceProperty).GetValue(_propertyEditor.CurrentObject));
        }
Esempio n. 4
0
 void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action<IEnumerable<string>, bool> itemsCalculated) {
     CompositeView compositeView = _propertyEditor.View;
     if (compositeView!=null) {
         compositeView.ObjectSpace.ObjectChanged += (sender, args) => {
             var comboBoxItems = GetComboBoxItems(dataSourcePropertyAttribute);
             itemsCalculated.Invoke(comboBoxItems,true);
         };
         itemsCalculated.Invoke(GetComboBoxItems(dataSourcePropertyAttribute),false);
     }
 }
        protected override WebControl CreateEditModeControlCore()
        {
            bool flag = false;

            if (base.CurrentObject != null)
            {
                Func <IMemberInfo, bool>    predicate = null;
                DataSourcePropertyAttribute dataSourcePropertyAttribute = base.MemberInfo.FindAttribute <DataSourcePropertyAttribute>();
                if (dataSourcePropertyAttribute != null)
                {
                    FieldInfo info = typeof(ASPxStringPropertyEditor).GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).FirstOrDefault <FieldInfo>(x => x.Name.Equals("predefinedValues"));
                    if (info != null)
                    {
                        if (predicate == null)
                        {
                            predicate = x => x.Name.Equals(dataSourcePropertyAttribute.DataSourceProperty);
                        }
                        IMemberInfo info2 = base.ObjectTypeInfo.Members.FirstOrDefault <IMemberInfo>(predicate);
                        if (info2 != null)
                        {
                            object obj2 = info2.GetValue(base.CurrentObject);
                            if (obj2 is string)
                            {
                                info.SetValue(this, obj2);
                            }
                            IEnumerable <string> source = obj2 as IEnumerable <string>;
                            if (source != null)
                            {
                                string str = source.Aggregate <string, string>(string.Empty, (current, s) => current + s + ";");
                                if (str.Length > 0)
                                {
                                    str = str.Remove(str.Length - 1);
                                    info.SetValue(this, str);
                                }
                            }
                        }
                    }
                    flag = true;
                }
            }
            WebControl control = base.CreateEditModeControlCore();

            if (flag && (control is ASPxDropDownEditBase))
            {
                ((ASPxDropDownEditBase)control).AllowUserInput  = false;
                ((ASPxDropDownEditBase)control).ShowShadow      = true;
                ((ASPxDropDownEditBase)control).AllowMouseWheel = true;
                if (control is ASPxComboBox)
                {
                    ((ASPxComboBox)control).DropDownStyle = DropDownStyle.DropDownList;
                }
            }
            return(control);
        }
Esempio n. 6
0
 void BuildFromDatasourceCore(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action <IEnumerable <string>, bool> itemsCalculated, Func <bool> itemsCalculating, string propertyName)
 {
     if (_propertyEditor.PropertyName != propertyName)
     {
         var invoke = itemsCalculating.Invoke();
         if (!invoke)
         {
             var comboBoxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
             itemsCalculated.Invoke(comboBoxItems, true);
         }
     }
 }
Esempio n. 7
0
 void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action<IEnumerable<string>, bool> itemsCalculated, Func<bool> itemsCalculating) {
     CompositeView compositeView = _propertyEditor.View;
     if (compositeView != null) {
         if (_propertyEditor.ObjectTypeInfo.IsPersistent) {
             compositeView.ObjectSpace.ObjectChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
         } else {
             ((INotifyPropertyChanged)_propertyEditor.CurrentObject).PropertyChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
         }
         var b = itemsCalculating.Invoke();
         if (!b) {
             var boxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
             itemsCalculated.Invoke(boxItems, false);
         }
     }
 }
Esempio n. 8
0
        void BuildFromDataSourceWhenCurrentObjectChanges(DataSourcePropertyAttribute dataSourcePropertyAttribute,
                                                         Action<IEnumerable<string>, bool> itemsCalculated, Func<bool> itemsCalculating,
                                                         PropertyChangedEventHandler propertyChangedEventHandler) {
            _propertyEditor.CurrentObjectChanged += (sender, args) => {
                var currentObject = _propertyEditor.CurrentObject as INotifyPropertyChanged;
                if (!_propertyEditor.ObjectTypeInfo.IsPersistent && currentObject != null)
                    currentObject.PropertyChanged += propertyChangedEventHandler;
                BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, null);
            };

            _propertyEditor.CurrentObjectChanging += (sender, args) => {
                var currentObject = _propertyEditor.CurrentObject as INotifyPropertyChanged;
                if (!_propertyEditor.ObjectTypeInfo.IsPersistent && currentObject != null)
                    currentObject.PropertyChanged -= propertyChangedEventHandler;
            };
        }
Esempio n. 9
0
        void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action<IEnumerable<string>, bool> itemsCalculated, Func<bool> itemsCalculating) {
            PropertyChangedEventHandler propertyChangedEventHandler = (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);

            if (_propertyEditor.ObjectTypeInfo.IsPersistent) {
                ((IObjectSpaceHolder)_propertyEditor).ObjectSpace.ObjectChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
            } else {
                var currentObject = _propertyEditor.CurrentObject as INotifyPropertyChanged;
                if (currentObject != null)
                    ((INotifyPropertyChanged)_propertyEditor.CurrentObject).PropertyChanged += propertyChangedEventHandler;
            }

            BuildFromDataSourceWhenCurrentObjectChanges(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, propertyChangedEventHandler);

            var b = itemsCalculating.Invoke();
            if (!b) {
                var boxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
                itemsCalculated.Invoke(boxItems, false);
            }
        }
Esempio n. 10
0
        void BuildFromDataSourceWhenCurrentObjectChanges(DataSourcePropertyAttribute dataSourcePropertyAttribute,
                                                         Action <IEnumerable <string>, bool> itemsCalculated, Func <bool> itemsCalculating,
                                                         PropertyChangedEventHandler propertyChangedEventHandler)
        {
            _propertyEditor.CurrentObjectChanged += (sender, args) => {
                if (!_propertyEditor.ObjectTypeInfo.IsPersistent && _propertyEditor.CurrentObject is INotifyPropertyChanged currentObject)
                {
                    currentObject.PropertyChanged += propertyChangedEventHandler;
                }
                BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, null);
            };

            _propertyEditor.CurrentObjectChanging += (sender, args) => {
                if (!_propertyEditor.ObjectTypeInfo.IsPersistent && _propertyEditor.CurrentObject is INotifyPropertyChanged currentObject)
                {
                    currentObject.PropertyChanged -= propertyChangedEventHandler;
                }
            };
        }
Esempio n. 11
0
        void BuildFromDatasource(DataSourcePropertyAttribute dataSourcePropertyAttribute, Action <IEnumerable <string>, bool> itemsCalculated, Func <bool> itemsCalculating)
        {
            CompositeView compositeView = _propertyEditor.View;

            if (compositeView != null)
            {
                if (_propertyEditor.ObjectTypeInfo.IsPersistent)
                {
                    compositeView.ObjectSpace.ObjectChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
                }
                else
                {
                    ((INotifyPropertyChanged)_propertyEditor.CurrentObject).PropertyChanged += (sender, args) => BuildFromDatasourceCore(dataSourcePropertyAttribute, itemsCalculated, itemsCalculating, args.PropertyName);
                }
                var b = itemsCalculating.Invoke();
                if (!b)
                {
                    var boxItems = GetComboBoxItemsCore(dataSourcePropertyAttribute);
                    itemsCalculated.Invoke(boxItems, false);
                }
            }
        }
Esempio n. 12
0
 IEnumerable <string> GetComboBoxItemsCore(DataSourcePropertyAttribute dataSourcePropertyAttribute)
 {
     return((IEnumerable <string>)_propertyEditor.ObjectTypeInfo.FindMember(dataSourcePropertyAttribute.DataSourceProperty).GetValue(_propertyEditor.CurrentObject));
 }
Esempio n. 13
0
 IEnumerable<string> GetComboBoxItemsCore(DataSourcePropertyAttribute dataSourcePropertyAttribute) {
     return ((IEnumerable<string>)_propertyEditor.View.ObjectTypeInfo.FindMember(dataSourcePropertyAttribute.DataSourceProperty).GetValue(_propertyEditor.CurrentObject));
 }