public RowItem(RowItem parent, IdentifierPath sublistId, object key, object value) { Parent = parent; SublistId = sublistId; Key = key; Value = value; }
private RowKey GetRowKey(RowItem rowItem) { if (rowItem.SublistId.IsRoot) { return(null); } return(new RowKey(GetRowKey(rowItem.Parent), rowItem.SublistId, rowItem.Key)); }
public void SetValue(RowItem rowItem, PivotKey pivotKey, object value) { if (IsReadOnly) { throw new InvalidOperationException(Resources.DisplayColumn_SetValue_Column_is_read_only); } ColumnDescriptor.SetValue(rowItem, pivotKey, value); }
public override void SetValue(RowItem rowItem, PivotKey pivotKey, object value) { var parentComponent = Parent.GetPropertyValue(rowItem, pivotKey); if (parentComponent == null) { return; } _propertyDescriptor.SetValue(parentComponent, value); }
public RowNode Expand(RowItem rowItem) { var root = new RowNode(rowItem); for (int currentColumnIndex = 0; currentColumnIndex < CollectionColumns.Count;) { currentColumnIndex = Expand(root, currentColumnIndex); } return(root); }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { if (null != pivotKey) { if (!rowItem.PivotKeys.Contains(pivotKey)) { return(null); } } return(rowItem.Value); }
public SortRow(DataSchema dataSchema, ListSortDescriptionCollection sorts, RowItem rowItem, int rowIndex) { DataSchema = dataSchema; Sorts = sorts; RowItem = rowItem; OriginalRowIndex = rowIndex; _keys = new object[sorts.Count]; for (int i = 0; i < sorts.Count; i++) { _keys[i] = sorts[i].PropertyDescriptor.GetValue(RowItem); } }
public object GetValue(RowItem rowItem, PivotKey pivotKey) { if (rowItem == null) { return null; } if (ColumnDescriptor == null) { return "#COLUMN " + PropertyPath + " NOT FOUND#"; // Not L10N } return ColumnDescriptor.GetPropertyValue(rowItem, pivotKey); }
public object GetValue(RowItem rowItem, PivotKey pivotKey) { if (rowItem == null) { return(null); } if (ColumnDescriptor == null) { return(@"#COLUMN " + PropertyPath + @" NOT FOUND#"); } return(ColumnDescriptor.GetPropertyValue(rowItem, pivotKey)); }
/// <summary> /// Writes out a row containing the formatted values /// </summary> public virtual void WriteDataRow(TextWriter writer, RowItem rowItem, IEnumerable<PropertyDescriptor> propertyDescriptors) { bool first = true; foreach (var pd in propertyDescriptors) { if (!first) { writer.Write(Separator); } first = false; writer.Write(ToDsvField(GetFormattedValue(rowItem, pd))); } writer.WriteLine(); }
private IEnumerable <object> AllRowValues(RowItem rowItem) { foreach (var columnDescriptor in ColumnDescriptors) { foreach (var pivotKey in PivotKeys) { yield return(columnDescriptor.GetPropertyValue(rowItem, pivotKey)); } } foreach (var dataPropertyDescriptor in DataPropertyDescriptors) { yield return(dataPropertyDescriptor.GetValue(rowItem)); } }
/// <summary> /// Writes out a row containing the formatted values /// </summary> public virtual void WriteDataRow(TextWriter writer, RowItem rowItem, IEnumerable <PropertyDescriptor> propertyDescriptors) { bool first = true; foreach (var pd in propertyDescriptors) { if (!first) { writer.Write(Separator); } first = false; writer.Write(ToDsvField(GetFormattedValue(rowItem, pd))); } writer.WriteLine(); }
protected virtual string GetFormattedValue(RowItem rowItem, PropertyDescriptor propertyDescriptor) { CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldUiCulture = Thread.CurrentThread.CurrentUICulture; try { Thread.CurrentThread.CurrentCulture = FormatProvider; Thread.CurrentThread.CurrentUICulture = Language; object value = GetValue(rowItem, propertyDescriptor); if (null == value) { var formatAttribute = (FormatAttribute)propertyDescriptor.Attributes[typeof(FormatAttribute)]; if (null == formatAttribute) { return(string.Empty); } return(formatAttribute.NullValue); } if (value is double || value is float) { var formatAttribute = (FormatAttribute)propertyDescriptor.Attributes[typeof(FormatAttribute)]; try { var doubleValue = Convert.ToDouble(value); if (null != NumberFormatOverride) { return(doubleValue.ToString(NumberFormatOverride, FormatProvider)); } if (null == formatAttribute || null == formatAttribute.Format) { return(doubleValue.ToString(FormatProvider)); } return(doubleValue.ToString(formatAttribute.Format, FormatProvider)); } catch (Exception) { return(value.ToString()); } } return(value.ToString()); } finally { Thread.CurrentThread.CurrentUICulture = oldUiCulture; Thread.CurrentThread.CurrentCulture = oldCulture; } }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { object parentValue = Parent.GetPropertyValue(rowItem, pivotKey); if (null == parentValue) { return(null); } try { return(_propertyDescriptor.GetValue(parentValue)); } catch { return(null); } }
public RowItem ApplyFilter(RowItem rowItem) { var predicate = Predicate; if (CollectionColumn.PropertyPath.IsRoot || rowItem.RowKey.Contains(CollectionColumn.PropertyPath)) { if (predicate(ColumnDescriptor.GetPropertyValue(rowItem, null))) { return(rowItem); } return(null); } if (rowItem.PivotKeyCount == 0) { return(FilterSpec.Predicate.FilterOperation == FilterOperations.OP_IS_BLANK ? rowItem : null); } List <PivotKey> newPivotKeys = new List <PivotKey>(); bool anyPivotKeysLeft = false; foreach (var pivotKey in rowItem.PivotKeys) { if (!pivotKey.Contains(CollectionColumn.PropertyPath)) { newPivotKeys.Add(pivotKey); } else { object value = ColumnDescriptor.GetPropertyValue(rowItem, pivotKey); if (predicate(value)) { newPivotKeys.Add(pivotKey); anyPivotKeysLeft = true; } } } if (newPivotKeys.Count == rowItem.PivotKeyCount) { return(rowItem); } if (!anyPivotKeysLeft) { return(null); } return(rowItem.SetPivotKeys(new HashSet <PivotKey>(newPivotKeys))); }
private IEnumerable <object> GetAllValues(object rootObject) { if (Pivoter == null) { return(new[] { GetSingleValue(rootObject) }); } var columnDescriptor = ViewInfo.DisplayColumns[0].ColumnDescriptor; var rowItem = new RowItem(rootObject); if (Pivoter == null) { return(new[] { columnDescriptor.GetPropertyValue(rowItem, null) }); } var pivotedRows = Pivoter.ExpandAndPivot(ViewInfo.DataSchema.QueryLock.CancellationToken, new[] { rowItem }); return(pivotedRows.RowItems.Select(item => columnDescriptor.GetPropertyValue(item, null))); }
public object GetPropertyValue(RowItem rowItem, RowKey rowKey) { while (!IdPath.StartsWith(rowItem.SublistId)) { rowItem = rowItem.Parent; } if (IdPath.Equals(rowItem.SublistId)) { return(rowItem.Value); } var parentValue = Parent.GetPropertyValue(rowItem, rowKey); if (parentValue == null) { return(null); } return(GetPropertyValueFromParent(parentValue, rowKey)); }
public RowItem ApplyFilter(RowItem rowItem) { var predicate = Predicate; if (CollectionColumn.PropertyPath.IsRoot || rowItem.RowKey.Contains(CollectionColumn.PropertyPath)) { if (predicate(ColumnDescriptor.GetPropertyValue(rowItem, null))) { return rowItem; } return null; } if (rowItem.PivotKeys.Count == 0) { return FilterSpec.Operation == FilterOperations.OP_IS_BLANK ? rowItem : null; } List<PivotKey> newPivotKeys = new List<PivotKey>(); bool anyPivotKeysLeft = false; foreach (var pivotKey in rowItem.PivotKeys) { if (!pivotKey.Contains(CollectionColumn.PropertyPath)) { newPivotKeys.Add(pivotKey); } else { object value = ColumnDescriptor.GetPropertyValue(rowItem, pivotKey); if (predicate(value)) { newPivotKeys.Add(pivotKey); anyPivotKeysLeft = true; } } } if (newPivotKeys.Count == rowItem.PivotKeys.Count) { return rowItem; } if (!anyPivotKeysLeft) { return null; } return rowItem.SetPivotKeys(new HashSet<PivotKey>(newPivotKeys)); }
protected virtual string GetFormattedValue(RowItem rowItem, PropertyDescriptor propertyDescriptor) { CultureInfo oldCulture = Thread.CurrentThread.CurrentCulture; CultureInfo oldUiCulture = Thread.CurrentThread.CurrentUICulture; try { Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = CultureInfo; object value = GetValue(rowItem, propertyDescriptor); if (null == value) { var formatAttribute = (FormatAttribute) propertyDescriptor.Attributes[typeof (FormatAttribute)]; if (null == formatAttribute) { return string.Empty; } return formatAttribute.NullValue; } if (value is double || value is float) { var formatAttribute = (FormatAttribute) propertyDescriptor.Attributes[typeof (FormatAttribute)]; try { var doubleValue = Convert.ToDouble(value); if (null == formatAttribute || null == formatAttribute.Format) { return doubleValue.ToString(CultureInfo); } return doubleValue.ToString(formatAttribute.Format, CultureInfo); } catch (Exception) { return value.ToString(); } } return value.ToString(); } finally { Thread.CurrentThread.CurrentUICulture = oldUiCulture; Thread.CurrentThread.CurrentCulture = oldCulture; } }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { var collection = Parent.GetPropertyValue(rowItem, pivotKey); if (null == collection) { return(null); } object key = rowItem.RowKey.FindValue(PropertyPath); if (null == key && null != pivotKey) { key = pivotKey.FindValue(PropertyPath); } if (null == key) { return(null); } return(_collectionInfo.GetItemFromKey(collection, key)); }
protected virtual object GetValue(RowItem rowItem, PropertyDescriptor propertyDescriptor) { return propertyDescriptor.GetValue(rowItem); }
private ChromFileInfoId GetChromFileInfoId(RowItem rowItem) { if (null == rowItem) { return null; } var result = rowItem.Value as Result; if (null != result) { return result.GetResultFile().ChromFileInfoId; } return null; }
private int? GetReplicateIndex(RowItem rowItem) { if (rowItem == null) { return null; } var replicate = rowItem.Value as Replicate; if (null != replicate) { return replicate.ReplicateIndex; } var result = rowItem.Value as Result; if (null != result) { return result.GetResultFile().Replicate.ReplicateIndex; } return null; }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { if (null != pivotKey) { if (!rowItem.PivotKeys.Contains(pivotKey)) { return null; } } return rowItem.Value; }
protected RowItem(RowItem copy) { Value = copy.Value; RowKey = copy.RowKey; PivotKeys = copy.PivotKeys; }
public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value) { }
protected virtual object GetValue(RowItem rowItem, PropertyDescriptor propertyDescriptor) { return(propertyDescriptor.GetValue(rowItem)); }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { var collection = Parent.GetPropertyValue(rowItem, pivotKey); if (null == collection) { return null; } object key = rowItem.RowKey.FindValue(PropertyPath); if (null == key && null != pivotKey) { key = pivotKey.FindValue(PropertyPath); } if (null == key) { return null; } return _collectionInfo.GetItemFromKey(collection, key); }
public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);
public IEnumerable <object> GetRowValues(RowItem rowItem) { return(AllRowValues(rowItem).Where(PropertyType.IsInstanceOfType)); }
public RowNode(RowItem rowItem) { RowItem = rowItem; _children = new Dictionary <IdentifierPath, ICollection <RowNode> >(); }
public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { object parentValue = Parent.GetPropertyValue(rowItem, pivotKey); if (null == parentValue) { return null; } try { return _propertyDescriptor.GetValue(parentValue); } catch { return null; } }
protected virtual string GetFormattedValue(RowItem rowItem, PropertyDescriptor propertyDescriptor) { object value = GetValue(rowItem, propertyDescriptor); if (null == value) { var formatAttribute = (FormatAttribute)propertyDescriptor.Attributes[typeof(FormatAttribute)]; if (null == formatAttribute) { return string.Empty; } return formatAttribute.NullValue; } if (value is double || value is float) { var formatAttribute = (FormatAttribute)propertyDescriptor.Attributes[typeof(FormatAttribute)]; try { var doubleValue = Convert.ToDouble(value); if (null == formatAttribute || null == formatAttribute.Format) { return doubleValue.ToString(FormatProvider); } return doubleValue.ToString(formatAttribute.Format, FormatProvider); } catch (Exception) { return value.ToString(); } } return value.ToString(); }