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

            return(_pivotKeys.Contains(pivotKey));
        }
Example #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);
            }
Example #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);
     }
 }
Example #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>());
        }
Example #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));
 }
Example #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));
 }
Example #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));
 }
Example #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);
                }
            }
Example #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));
        }
Example #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));
        }
Example #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);
        }
Example #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));
            }
Example #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>());
        }
Example #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
        }
Example #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();
     }
 }
Example #25
0
 public RowItem SetRowKey(PivotKey rowKey)
 {
     return(ChangeProp(ImClone(this), im => im.RowKey = rowKey));
 }
Example #26
0
 public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);
Example #27
0
 public RowItem(object value, PivotKey rowKey, IEnumerable <PivotKey> pivotKeys)
 {
     Value     = value;
     RowKey    = rowKey;
     PivotKeys = ImmutableList.ValueOf(pivotKeys);
 }
Example #28
0
 public string GetColumnCaption(PivotKey pivotKey, ColumnCaptionType captionType)
 {
     return(GetColumnCaption(pivotKey).GetCaption(captionType == ColumnCaptionType.invariant
         ? DataSchemaLocalizer.INVARIANT
         : DataSchema.DataSchemaLocalizer));
 }
Example #29
0
 public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value)
 {
 }