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); } }
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); } } }
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)); }
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); }
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); } } }
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); } } }
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; }; }
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); } }
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; } }; }
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); } } }
IEnumerable <string> GetComboBoxItemsCore(DataSourcePropertyAttribute dataSourcePropertyAttribute) { return((IEnumerable <string>)_propertyEditor.ObjectTypeInfo.FindMember(dataSourcePropertyAttribute.DataSourceProperty).GetValue(_propertyEditor.CurrentObject)); }
IEnumerable<string> GetComboBoxItemsCore(DataSourcePropertyAttribute dataSourcePropertyAttribute) { return ((IEnumerable<string>)_propertyEditor.View.ObjectTypeInfo.FindMember(dataSourcePropertyAttribute.DataSourceProperty).GetValue(_propertyEditor.CurrentObject)); }