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); }
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); } }