public ColumnPropertyDescriptor(DisplayColumn displayColumn, string name, PropertyPath propertyPath, PivotKey pivotKey) : base(name, displayColumn.GetAttributes(pivotKey).ToArray()) { DisplayColumn = displayColumn; PropertyPath = propertyPath; PivotKey = pivotKey; }
public RowItem SetRowKey(PivotKey rowKey) { return(new RowItem(this) { RowKey = rowKey }); }
/// <summary> /// Take the values from the PivotKey and plug them into the unbound (i.e. name=null) /// parts of the PropertyPath. /// </summary> public static PropertyPath QualifyPropertyPath(PivotKey pivotKey, PropertyPath propertyPath) { if (pivotKey == null || propertyPath.IsRoot) { return(propertyPath); } var parent = QualifyPropertyPath(pivotKey, propertyPath.Parent); if (propertyPath.IsUnboundLookup) { object value = pivotKey.FindValue(propertyPath); if (null != value) { return(parent.LookupByKey(value.ToString())); } } if (ReferenceEquals(parent, propertyPath.Parent)) { return(propertyPath); } if (propertyPath.IsUnboundLookup) { return(parent.LookupAllItems()); } if (propertyPath.IsProperty) { return(parent.Property(propertyPath.Name)); } return(parent.LookupByKey(propertyPath.Name)); }
public ColumnPropertyDescriptor(DisplayColumn displayColumn, string name, PropertyPath propertyPath, PivotKey pivotKey) : base(name, displayColumn.GetColumnCaption(pivotKey), displayColumn.DataSchema.DataSchemaLocalizer, displayColumn.GetAttributes(pivotKey).ToArray()) { DisplayColumn = displayColumn; PropertyPath = propertyPath; PivotKey = pivotKey; }
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 string GetColumnDescription(PivotKey pivotKey) { if (ColumnDescriptor == null) { return(null); } return(DataSchema.GetColumnDescription(ColumnDescriptor)); }
public static IColumnCaption QualifyColumnCaption(PivotKey pivotKey, IColumnCaption columnCaption) { if (null == pivotKey) { return(columnCaption); } return(QualifyColumnCaption(pivotKey.KeyPairs.Select(pair => pair.Value), columnCaption)); }
public PivotKey(IEnumerable <KeyValuePair <PropertyPath, object> > keyPairs) { Parent = EMPTY; foreach (var keyPair in keyPairs) { Parent = new PivotKey(Parent, keyPair.Key, keyPair.Value); } }
public bool ContainsPivotKey(PivotKey pivotKey) { if (_pivotKeys == null) { return(false); } return(_pivotKeys.Contains(pivotKey)); }
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 override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey) { if (null != pivotKey) { if (!rowItem.PivotKeys.Contains(pivotKey)) { return(null); } } return(rowItem.Value); }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (PropertyPath != null ? PropertyPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PivotKey != null ? PivotKey.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DisplayColumn != null ? DisplayColumn.GetHashCode() : 0); return(hashCode); } }
public IEnumerable <Attribute> GetAttributes(PivotKey pivotKey) { if (null == ColumnDescriptor) { return(new Attribute[0]); } var overrideAttributes = new Attribute[] { new DisplayNameAttribute(GetColumnCaption(pivotKey, ColumnCaptionType.localized)) }; var mergedAttributes = AttributeCollection.FromExisting(new AttributeCollection(ColumnDescriptor.GetAttributes().ToArray()), overrideAttributes); return(mergedAttributes.Cast <Attribute>()); }
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)); }
public PivotKey Concat(PivotKey pivotKey) { if (Length == 0) { return(pivotKey); } if (pivotKey.Length == 0) { return(this); } return(new PivotKey(Concat(pivotKey.Parent), pivotKey.PropertyPath, pivotKey.Value)); }
public bool Equals(PivotKey other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Equals(Parent, other.Parent) && Equals(PropertyPath, other.PropertyPath) && Equals(Value, other.Value)); }
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 IColumnCaption GetColumnCaption(PivotKey pivotKey) { IColumnCaption columnCaption; if (null != ColumnSpec.Caption) { columnCaption = ColumnCaption.UnlocalizableCaption(ColumnSpec.Caption); } else if (null == ColumnDescriptor) { columnCaption = ColumnCaption.UnlocalizableCaption(PropertyPath.ToString()); } else { columnCaption = DataSchema.GetColumnCaption(ColumnDescriptor); } return(QualifyColumnCaption(pivotKey, columnCaption)); }
public string GetColumnCaption(PivotKey pivotKey, ColumnCaptionType columnCaptionType) { string columnCaption; if (null != ColumnSpec.Caption) { columnCaption = ColumnSpec.Caption; } else if (null == ColumnDescriptor) { columnCaption = PropertyPath.ToString(); } else { columnCaption = DataSchema.GetColumnCaption(DataSchema.GetColumnCaption(ColumnDescriptor), columnCaptionType); } return(QualifyColumnCaption(pivotKey, columnCaption)); }
public static PivotKey GetPivotKey(IDictionary <PivotKey, PivotKey> pivotKeys, IEnumerable <KeyValuePair <PropertyPath, object> > keyPairs) { var result = EMPTY; foreach (var entry in keyPairs) { result = new PivotKey(result, entry.Key, entry.Value); PivotKey existing; if (pivotKeys.TryGetValue(result, out existing)) { result = existing; } else { pivotKeys.Add(result, result); } } return(result); }
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 IEnumerable <Attribute> GetAttributes(PivotKey pivotKey) { if (null == ColumnDescriptor) { return(new Attribute[0]); } var columnCaption = GetColumnCaption(pivotKey); var overrideAttributes = new List <Attribute> { new DisplayNameAttribute(columnCaption.GetCaption(DataSchema.DataSchemaLocalizer)), new ColumnCaptionAttribute(columnCaption) }; if (ColumnDescriptor.IsExpensive) { overrideAttributes.Add(new ExpensiveAttribute()); } var mergedAttributes = AttributeCollection.FromExisting(new AttributeCollection(ColumnDescriptor.GetAttributes().ToArray()), overrideAttributes.ToArray()); return(mergedAttributes.Cast <Attribute>()); }
public static string QualifyColumnCaption(PivotKey pivotKey, string columnCaption) { if (null == pivotKey) { return(columnCaption); } StringBuilder prefix = new StringBuilder(); foreach (var kvp in pivotKey.KeyPairs) { if (prefix.Length > 0) { prefix.Append(" "); // Not L10N } prefix.Append(kvp.Value ?? string.Empty); } if (prefix.Length == 0) { return(columnCaption); } return(prefix + " " + columnCaption); // Not L10N }
public PivotKey(PivotKey parent, PropertyPath propertyPath, object value) { Parent = parent; if (null != parent) { Length = parent.Length + 1; } PropertyPath = propertyPath; Value = value; if (null != Parent) { Length = Parent.Length + 1; _hashCode = Parent.GetHashCode(); } else { Length = 1; } _hashCode = _hashCode * 397 ^ PropertyPath.GetHashCode(); if (Value != null) { _hashCode = _hashCode * 397 ^ Value.GetHashCode(); } }
public RowItem SetRowKey(PivotKey rowKey) { return(ChangeProp(ImClone(this), im => im.RowKey = rowKey)); }
public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);
public RowItem(object value, PivotKey rowKey, IEnumerable <PivotKey> pivotKeys) { Value = value; RowKey = rowKey; PivotKeys = ImmutableList.ValueOf(pivotKeys); }
public string GetColumnCaption(PivotKey pivotKey, ColumnCaptionType captionType) { return(GetColumnCaption(pivotKey).GetCaption(captionType == ColumnCaptionType.invariant ? DataSchemaLocalizer.INVARIANT : DataSchema.DataSchemaLocalizer)); }
public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value) { }