Пример #1
0
 public RowItem(RowItem parent, IdentifierPath sublistId, object key, object value)
 {
     Parent    = parent;
     SublistId = sublistId;
     Key       = key;
     Value     = value;
 }
Пример #2
0
 private RowKey GetRowKey(RowItem rowItem)
 {
     if (rowItem.SublistId.IsRoot)
     {
         return(null);
     }
     return(new RowKey(GetRowKey(rowItem.Parent), rowItem.SublistId, rowItem.Key));
 }
Пример #3
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);
 }
Пример #4
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);
            }
Пример #5
0
        public RowNode Expand(RowItem rowItem)
        {
            var root = new RowNode(rowItem);

            for (int currentColumnIndex = 0; currentColumnIndex < CollectionColumns.Count;)
            {
                currentColumnIndex = Expand(root, currentColumnIndex);
            }
            return(root);
        }
Пример #6
0
 public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey)
 {
     if (null != pivotKey)
     {
         if (!rowItem.PivotKeys.Contains(pivotKey))
         {
             return(null);
         }
     }
     return(rowItem.Value);
 }
Пример #7
0
 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);
     }
 }
Пример #8
0
 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);
 }
Пример #9
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));
 }
Пример #10
0
 /// <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();
 }
Пример #11
0
        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));
            }
        }
Пример #12
0
        /// <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();
        }
Пример #13
0
        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;
            }
        }
Пример #14
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);
                }
            }
Пример #15
0
        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)));
        }
Пример #16
0
        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)));
        }
Пример #17
0
        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));
        }
Пример #18
0
 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));
 }
Пример #19
0
 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;
     }
 }
Пример #20
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));
            }
Пример #21
0
 protected virtual object GetValue(RowItem rowItem, PropertyDescriptor propertyDescriptor)
 {
     return propertyDescriptor.GetValue(rowItem);
 }
Пример #22
0
 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;
 }
Пример #23
0
 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;
 }
Пример #24
0
 public override object GetPropertyValue(RowItem rowItem, PivotKey pivotKey)
 {
     if (null != pivotKey)
     {
         if (!rowItem.PivotKeys.Contains(pivotKey))
         {
             return null;
         }
     }
     return rowItem.Value;
 }
Пример #25
0
 protected RowItem(RowItem copy)
 {
     Value = copy.Value;
     RowKey = copy.RowKey;
     PivotKeys = copy.PivotKeys;
 }
Пример #26
0
 public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value)
 {
 }
Пример #27
0
 protected virtual object GetValue(RowItem rowItem, PropertyDescriptor propertyDescriptor)
 {
     return(propertyDescriptor.GetValue(rowItem));
 }
Пример #28
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);
 }
Пример #29
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);
 }
Пример #30
0
 public virtual void SetValue(RowItem rowItem, PivotKey pivotKey, object value)
 {
 }
Пример #31
0
 public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);
Пример #32
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);
 }
Пример #33
0
 public IEnumerable <object> GetRowValues(RowItem rowItem)
 {
     return(AllRowValues(rowItem).Where(PropertyType.IsInstanceOfType));
 }
Пример #34
0
 protected RowItem(RowItem copy)
 {
     Value     = copy.Value;
     RowKey    = copy.RowKey;
     PivotKeys = copy.PivotKeys;
 }
Пример #35
0
 public RowNode(RowItem rowItem)
 {
     RowItem   = rowItem;
     _children = new Dictionary <IdentifierPath, ICollection <RowNode> >();
 }
Пример #36
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;
     }
 }
Пример #37
0
 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();
 }
Пример #38
0
 public abstract object GetPropertyValue(RowItem rowItem, PivotKey pivotKey);