/// <summary> /// Returns ValueExpressionFunc for corresponding column and data operation /// </summary> /// <param name="view">CollectionViewAdv</param> /// <param name="column">Column</param> /// <param name="operation">DataOperation</param> /// <param name="mode">DataReflectionMode</param> /// <param name="useBindingValue">useBindingvalue</param> /// <returns>Expression<Func<string, object, object>></returns> public static System.Linq.Expressions.Expression <Func <string, object, object> > GetValueExpressionFunc(this CollectionViewAdv view, GridColumn column, DataOperation operation, DataReflectionMode mode, bool useBindingValue) { if (column != null && column.IsUnbound) { var unboundcolumn = column as GridUnBoundColumn; var dataGrid = view.GetDataGrid() as SfDataGrid; view.GetUnboundFunc(dataGrid, unboundcolumn); if (unboundcolumn.UnBoundFunc != null) { return((columnName, record) => unboundcolumn.UnBoundFunc(columnName, record)); } return(null); } else if (mode == DataReflectionMode.Default) { if (column != null && column.ValueBinding != null && column.UseBindingValue) { return(view.GetBindingExpressionFunc()); } #if WPF if (view.IsITypedListSource()) { var func = view.GetITypedListExpressionFunc(column.MappingName); if (func != null) { return(func); } } #endif if (view.IsDynamicBound) { return(view.GetDynamicExpressionFunc()); } else if (view.IsXElementBound) { return(view.GetXElementAttributeFunc()); } } else if (mode == DataReflectionMode.Display) { return((propname, record) => view.GetPropertyAccessProvider().GetDisplayValue(record, propname, useBindingValue)); } else if (mode == DataReflectionMode.Value) { return((propName, record) => view.GetPropertyAccessProvider().GetValue(record, propName, useBindingValue)); } return(null); }
/// <summary> /// Returns XElement Func to reflect the value form XElement collection /// </summary> /// <param name="view">CollectionViewAdv</param> /// <returns>XElement Func </returns> internal static Func <string, object, object> GetXElementFunc(this CollectionViewAdv view) { return((propertyName, record) => { var xElementAttributesProvider = view.GetPropertyAccessProvider() as XElementAttributesProvider; return xElementAttributesProvider != null?xElementAttributesProvider.GetValue(record, propertyName) : null; }); }
/// <summary> /// Returns Binding Func to reflect the value form collection /// </summary> /// <param name="view">CollectionView</param> /// <returns>Binding Func</returns> internal static Func <string, object, object> GetBindingFunc(this CollectionViewAdv view) { return((propertyName, record) => { var provider = view.GetPropertyAccessProvider(); return provider.GetValue(record, propertyName); }); }
/// <summary> /// Returns Dynamic Func to reflect the value in dynamic collection /// </summary> /// <param name="view">CollectionViewAdv</param> /// <returns>Dynamic collection Func</returns> internal static Func <string, object, object> GetDynamicFunc(this CollectionViewAdv view) { return((propertyName, record) => { var dynamicProvider = view.GetPropertyAccessProvider() as DynamicPropertiesProvider; return dynamicProvider != null?dynamicProvider.GetValue(record, propertyName) : null; }); }
/// <summary> /// Return ValueFunc for based on corresponding column and DataOperationMode /// </summary> /// <param name="view">CollectionViewAdv</param> /// <param name="column">GridColumn</param> /// <param name="operation">DataOperation</param> /// <param name="mode">DataReflectionMode</param> /// <param name="useBindingValue">useBindingValue</param> /// <returns>Func<string, object, object></returns> public static Func <string, object, object> GetValueFunc(this CollectionViewAdv view, GridColumn column, DataOperation operation, DataReflectionMode mode, bool useBindingValue) { if (operation == DataOperation.Grouping) { var pgd = view.GroupDescriptions.OfType <ColumnGroupDescription>().FirstOrDefault(g => g.PropertyName == column.mappingName); if (pgd != null && pgd.Converter != null) { Func <string, object, object> groupConverterFunc = (columnName, record) => { //The ColumnName and the PropertyReflector helps to get the value to Group the Column with the Intervals. if (pgd.Converter is IColumnAccessProvider) { (pgd.Converter as IColumnAccessProvider).ColumnName = columnName; (pgd.Converter as IColumnAccessProvider).PropertyReflector = view.GetPropertyAccessProvider(); } return(pgd.Converter.Convert(record, record.GetType(), column, CultureInfo.CurrentCulture.GetCulture())); }; return(groupConverterFunc); } } if (column != null && column.IsUnbound) { var unboundcolumn = column as GridUnBoundColumn; var dataGrid = view.GetDataGrid() as SfDataGrid; return(view.GetUnboundFunc(dataGrid, unboundcolumn)); } else if (mode == DataReflectionMode.Default) { if (column != null && column.ValueBinding != null && column.UseBindingValue) { return(view.GetBindingFunc()); } #if WPF if (view.IsITypedListSource()) { var func = view.GetITypedListFunc(column.MappingName); if (func != null) { return(func); } } #endif if (view.IsDynamicBound) { return(view.GetDynamicFunc()); } if (view.IsXElementBound) { return(view.GetXElementFunc()); } } else if (mode == DataReflectionMode.Display) { return((propname, record) => view.GetPropertyAccessProvider().GetDisplayValue(record, propname, useBindingValue)); } else if (mode == DataReflectionMode.Value) { return((propName, record) => view.GetPropertyAccessProvider().GetValue(record, propName, useBindingValue)); } return(null); }