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); }
public async ValueTask <bool> IsDevice() { CellBlazorService CellService = this; if (CellService.JsRuntime != null) { await CellBaseUtils.InvokeDeviceMode(CellService, CellService.JsRuntime); } return(CellService.IsDeviceMode); }
public static async Task RippleEffect( IJSRuntime jsRuntime, object reference, object rippleSettings) { try { await CellBaseUtils.InvokeMethod(jsRuntime, "cellBlazor.callRipple", reference, rippleSettings); } catch (Exception ex) { object obj = await LogError <object>(jsRuntime, ex); } }
public static async Task Animate( IJSRuntime jsRuntime, object reference, object animationSettings) { try { await CellBaseUtils.InvokeMethod(jsRuntime, "cellBlazor.animate", reference, animationSettings); } catch (Exception ex) { object obj = await LogError <object>(jsRuntime, ex); } }
public static async ValueTask <T> SetTemplateInstance <T>( IJSRuntime jsRuntime, string templateName, DotNetObjectReference <object> helper, int guid) { try { return(await CellBaseUtils.InvokeMethod <T>(jsRuntime, "cellBlazor.setTemplateInstance", (object)templateName, (object)helper, (object)guid)); } catch (Exception ex) { return(await LogError <T>(jsRuntime, ex)); } }
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); } }
public static ValueTask <T> InvokeGet <T>( IJSRuntime jsRuntime, string id, string moduleName, string methodName, string nameSpace) { try { return(CellBaseUtils.InvokeMethod <T>(jsRuntime, "cellBlazor.getMethodCall", (object)id, (object)moduleName, (object)methodName)); } catch (Exception ex) { string message = nameSpace + " - #" + id + " - getMethodCall had public server error \n"; return(LogError <T>(jsRuntime, ex, message)); } }
public override async Task <object> PerformDataOperation <T>(object query) { BlazorAdaptor blazorAdaptor = this; IEnumerable DataSource = (IEnumerable)blazorAdaptor.DataManager.Json; DataManagerRequest queries = (DataManagerRequest)CellBaseUtils.ChangeType(query, typeof(DataManagerRequest)); DataResult DataObject; if (!blazorAdaptor.RunSyncOnce) { return(await Task.Run <object>((Func <object>)(() => { DataObject = this.DataOperationInvoke <T>(DataSource, queries); return !queries.RequiresCounts ? (object)DataObject.Result : (object)DataObject; }))); } blazorAdaptor.RunSyncOnce = false; DataObject = blazorAdaptor.DataOperationInvoke <T>(DataSource, queries); return(await Task.FromResult <object>(queries.RequiresCounts?(object)DataObject : (object)DataObject.Result)); }
protected override async Task OnAfterRenderAsync(bool firstRender) { CellBaseComponent cellBaseComponent = this; if (firstRender) { cellBaseComponent.DotnetObjectReference = DotNetObjectReference.Create <object>((object)cellBaseComponent); cellBaseComponent.IsRendered = firstRender; await CellBaseUtils.ImportModule(cellBaseComponent.JSRuntime, CellScriptModules.CellBase); await CellBaseUtils.InvokeDeviceMode(cellBaseComponent.SyncfusionService, cellBaseComponent.JSRuntime); await CellBaseUtils.ImportModules(cellBaseComponent.JSRuntime, cellBaseComponent.DependentScripts, cellBaseComponent.SyncfusionService.ScriptHashKey); if (cellBaseComponent.ScriptModules != CellScriptModules.None) { await CellBaseUtils.ImportModule(cellBaseComponent.JSRuntime, cellBaseComponent.ScriptModules, cellBaseComponent.SyncfusionService.ScriptHashKey); } await cellBaseComponent.OnAfterScriptRendered(); } cellBaseComponent.PropertyChanges?.Clear(); }
public async Task <T> InvokeMethod <T>( string methodName, bool isObjectReturnType, params object[] methodParams) { if (!isObjectReturnType) { return(await CellBaseUtils.InvokeMethod <T>(this.JSRuntime, methodName, methodParams)); } string str = await CellBaseUtils.InvokeMethod <string>(this.JSRuntime, methodName, methodParams); T obj = default(T); if (str != null) { obj = JsonConvert.DeserializeObject <T>(str, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); } return(obj); }
public async Task InvokeMethod(string methodName, params object[] methodParams) => await CellBaseUtils.InvokeMethod(this.JSRuntime, methodName, methodParams);
public override object ProcessQuery(DataManagerRequest queries) => CellBaseUtils.ChangeType((object)queries, typeof(DataManagerRequest));
public async Task <string> BaseRemove(string baseData, string keyField, string key) { object data; if (GenericType != null) { PropertyInfo propertyInfo = GenericType.GetProperty(keyField); if (propertyInfo == null) { foreach (PropertyInfo property in GenericType.GetProperties()) { foreach (object customAttribute in property.GetCustomAttributes()) { if (customAttribute is JsonPropertyAttribute && (customAttribute as JsonPropertyAttribute).PropertyName == keyField) { propertyInfo = property; } } } } Type propertyType = propertyInfo.PropertyType; data = propertyType.Name == "Guid" ? JsonConvert.DeserializeObject <Guid>(baseData) : CellBaseUtils.ChangeType(JsonConvert.DeserializeObject(baseData, DeserializeSettings), propertyType); } else { data = JsonConvert.DeserializeObject <object>(baseData, DeserializeSettings); } return(JsonConvert.SerializeObject(await Remove(data, keyField, key), Formatting.Indented, SerializeSettings)); }