private void ObservableCollectionChanged( string propertyName, object sender1, NotifyCollectionChangedEventArgs e1) { if (this.PropertyChanged == null) { this.PropertyChanged = (PropertyChangedEventHandler)((sender2, e2) => this.ObservablePropertyChanged(propertyName, sender2, e2)); } if (e1.Action == NotifyCollectionChangedAction.Remove) { foreach (object oldItem in (IEnumerable)e1.OldItems) { if (oldItem is INotifyPropertyChanged) { ((INotifyPropertyChanged)oldItem).PropertyChanged -= this.PropertyChanged; } } } else if (e1.Action == NotifyCollectionChangedAction.Add) { foreach (object newItem in (IEnumerable)e1.NewItems) { if (newItem is INotifyPropertyChanged) { ((INotifyPropertyChanged)newItem).PropertyChanged += this.PropertyChanged; } } } CellBaseUtils.UpdateDictionary(propertyName, sender1, this.PropertyChanges); this.OnObservableChange(propertyName, sender1, true); }
public virtual async Task <T> UpdateProperty <T>( string propertyName, T publicValue, T privateValue, object eventCallback = null, Expression <Func <T> > expression = null) { CellDataBoundComponent dataBoundComponent = this; T finalResult = publicValue; if (!EqualityComparer <T> .Default.Equals(publicValue, privateValue)) { T newValue = dataBoundComponent.DirectParameters.ContainsKey(propertyName) ? (T)dataBoundComponent.DirectParameters[propertyName] : publicValue; bool flag = eventCallback != null && ((EventCallback <T>)eventCallback).HasDelegate; bool isPropertyBinding = !CellBaseUtils.Equals(publicValue, newValue) && dataBoundComponent.IsRerendering; CellBaseComponent sfBaseComponent = dataBoundComponent.MainParent != null ? dataBoundComponent.MainParent : dataBoundComponent; finalResult = dataBoundComponent.IsRerendering & flag | isPropertyBinding || !sfBaseComponent.IsRendered ? publicValue : privateValue; if (flag) { await((EventCallback <T>)eventCallback).InvokeAsync(finalResult); } if (isPropertyBinding) { dataBoundComponent.DirectParameters[propertyName] = finalResult; CellBaseUtils.UpdateDictionary(propertyName, finalResult, dataBoundComponent.PropertyChanges); } } T obj = finalResult; finalResult = default; return(obj); }
private void ObservablePropertyChanged( string propertyName, object sender, PropertyChangedEventArgs e) { CellBaseUtils.UpdateDictionary(propertyName, sender, this.PropertyChanges); this.OnObservableChange(propertyName, sender); }
public T NotifyPropertyChanges <T>(string propertyName, T publicValue, T privateValue) { if (!CellBaseUtils.Equals <T>(publicValue, privateValue)) { CellBaseUtils.UpdateDictionary(propertyName, (object)publicValue, this.PropertyChanges); } return(publicValue); }
protected override async Task OnAfterRenderAsync(bool firstRender) { CellDataBoundComponent dataBoundComponent = this; if (!firstRender) { return; } foreach (string directParamKey in dataBoundComponent.directParamKeys) { dataBoundComponent.DirectParameters = dataBoundComponent.DirectParameters == null ? new Dictionary <string, object>() : dataBoundComponent.DirectParameters; PropertyInfo property = dataBoundComponent.GetType().GetProperty(directParamKey); object data = (object)property != null?property.GetValue(dataBoundComponent) : null; CellBaseUtils.UpdateDictionary(directParamKey, data, dataBoundComponent.DirectParameters); } }