public ColumnPropertyDescriptor(DisplayColumn displayColumn, string name, PropertyPath propertyPath, PivotKey pivotKey)
     : base(name, displayColumn.GetAttributes(pivotKey).ToArray())
 {
     DisplayColumn = displayColumn;
     PropertyPath  = propertyPath;
     PivotKey      = pivotKey;
 }
Beispiel #2
0
 public RowItem SetRowKey(PivotKey rowKey)
 {
     return(new RowItem(this)
     {
         RowKey = rowKey
     });
 }
Beispiel #3
0
        /// <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;
 }
Beispiel #5
0
 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);
 }
Beispiel #6
0
 public string GetColumnDescription(PivotKey pivotKey)
 {
     if (ColumnDescriptor == null)
     {
         return(null);
     }
     return(DataSchema.GetColumnDescription(ColumnDescriptor));
 }
Beispiel #7
0
 public static IColumnCaption QualifyColumnCaption(PivotKey pivotKey, IColumnCaption columnCaption)
 {
     if (null == pivotKey)
     {
         return(columnCaption);
     }
     return(QualifyColumnCaption(pivotKey.KeyPairs.Select(pair => pair.Value), columnCaption));
 }
Beispiel #8
0
 public PivotKey(IEnumerable <KeyValuePair <PropertyPath, object> > keyPairs)
 {
     Parent = EMPTY;
     foreach (var keyPair in keyPairs)
     {
         Parent = new PivotKey(Parent, keyPair.Key, keyPair.Value);
     }
 }
Beispiel #9
0
        public bool ContainsPivotKey(PivotKey pivotKey)
        {
            if (_pivotKeys == null)
            {
                return(false);
            }

            return(_pivotKeys.Contains(pivotKey));
        }
Beispiel #10
0
            public override void SetValue(RowItem rowItem, PivotKey pivotKey, object value)
            {
                var parentComponent = Parent.GetPropertyValue(rowItem, pivotKey);

                if (parentComponent == null)
                {
                    return;
                }
                _propertyDescriptor.SetValue(parentComponent, value);
            }
Beispiel #11
0
 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);
     }
 }
Beispiel #13
0
        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>());
        }
Beispiel #14
0
 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));
 }
Beispiel #15
0
 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));
 }
Beispiel #16
0
 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));
 }
Beispiel #17
0
            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);
                }
            }
Beispiel #18
0
        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));
        }
Beispiel #19
0
        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));
        }
Beispiel #20
0
        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);
        }
Beispiel #21
0
            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));
            }
Beispiel #22
0
        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>());
        }
Beispiel #23
0
        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
        }
Beispiel #24
0
 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();
     }
 }
Beispiel #25
0
 public RowItem SetRowKey(PivotKey rowKey)
 {
     return(ChangeProp(ImClone(this), im => im.RowKey = rowKey));
 }
Beispiel #26
0
 public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);
Beispiel #27
0
 public RowItem(object value, PivotKey rowKey, IEnumerable <PivotKey> pivotKeys)
 {
     Value     = value;
     RowKey    = rowKey;
     PivotKeys = ImmutableList.ValueOf(pivotKeys);
 }
Beispiel #28
0
 public string GetColumnCaption(PivotKey pivotKey, ColumnCaptionType captionType)
 {
     return(GetColumnCaption(pivotKey).GetCaption(captionType == ColumnCaptionType.invariant
         ? DataSchemaLocalizer.INVARIANT
         : DataSchema.DataSchemaLocalizer));
 }
Beispiel #29
0
 public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value)
 {
 }