Beispiel #1
0
 public ViewSpec SetSublistId(IdentifierPath sublistId)
 {
     return(new ViewSpec(this)
     {
         SublistId = sublistId
     });
 }
Beispiel #2
0
 public RowItem(RowItem parent, IdentifierPath sublistId, object key, object value)
 {
     Parent    = parent;
     SublistId = sublistId;
     Key       = key;
     Value     = value;
 }
Beispiel #3
0
 public ColumnSpec SetIdentifierPath(IdentifierPath value)
 {
     return(new ColumnSpec(this)
     {
         Name = value == null ? "" : value.ToString()
     });
 }
Beispiel #4
0
 public static IdentifierPath QualifyIdentifierPath(RowKey rowKey, IdentifierPath identifierPath)
 {
     if (rowKey == null)
     {
         return(identifierPath);
     }
     string[] parts = new string[identifierPath.Length];
     while (identifierPath.Length > 0)
     {
         parts[identifierPath.Length - 1] = identifierPath.Name;
         identifierPath = identifierPath.Parent;
     }
     while (rowKey != null)
     {
         if (rowKey.IdentifierPath.Length <= parts.Length)
         {
             parts[rowKey.IdentifierPath.Length - 1] = rowKey.Value.ToString();
         }
         rowKey = rowKey.Parent;
     }
     foreach (var part in parts)
     {
         identifierPath = new IdentifierPath(identifierPath, part);
     }
     return(identifierPath);
 }
Beispiel #5
0
        public IEnumerable <RowNode> GetChildren(IdentifierPath identifierPath)
        {
            ICollection <RowNode> children;

            if (_children.TryGetValue(identifierPath, out children))
            {
                return(children);
            }
            return(new RowNode[0]);
        }
Beispiel #6
0
 public ColumnDescriptor(ColumnDescriptor parent, string name, PropertyDescriptor propertyDescriptor)
 {
     DataSchema         = parent.DataSchema;
     Parent             = parent;
     IdPath             = new IdentifierPath(parent.IdPath, name);
     PropertyDescriptor = propertyDescriptor;
     if (PropertyDescriptor != null)
     {
         PropertyType = PropertyDescriptor.PropertyType;
         MapAttribute = PropertyDescriptor.Attributes.OfType <MapAttribute>().FirstOrDefault();
     }
 }
Beispiel #7
0
 public object FindValue(IdentifierPath key)
 {
     if (IdentifierPath.Equals(key))
     {
         return(Value);
     }
     if (Parent != null && key.Length < IdentifierPath.Length)
     {
         return(Parent.FindValue(key));
     }
     return(null);
 }
Beispiel #8
0
        public ColumnDescriptor ResolveDescendant(IdentifierPath identifierPath)
        {
            if (identifierPath.IsRoot)
            {
                return(this);
            }
            ColumnDescriptor parent = ResolveDescendant(identifierPath.Parent);

            if (parent == null)
            {
                return(null);
            }
            return(parent.ResolveChild(identifierPath.Name));
        }
Beispiel #9
0
        public ICollection <RowKey> GetPivotValues(IdentifierPath identifierPath)
        {
            var deepestId = IdentifierPath.Root;
            ICollection <RowKey> deepestResult = null;

            foreach (var entry in _pivotValues)
            {
                if (entry.Key.Length > deepestId.Length && identifierPath.StartsWith(entry.Key))
                {
                    deepestResult = entry.Value;
                }
            }
            return(deepestResult);
        }
Beispiel #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = 0;
         if (Parent != null)
         {
             result = result * 397 ^ Parent.GetHashCode();
         }
         result = result * 397 ^ IdentifierPath.GetHashCode();
         result = result * 397 ^ (ReferenceEquals(Value, null) ? 0 : Value.GetHashCode());
         return(result);
     }
 }
Beispiel #11
0
 private ColumnPropertyDescriptor(ColumnDescriptor columnDescriptor, IdentifierPath identifierPath) : base(ColumnPropertyDescriptorBaseName + identifierPath, new Attribute[0])
 {
     if (columnDescriptor.CollectionInfo != null && columnDescriptor.CollectionInfo.IsDictionary)
     {
         // Special case dictionary items.
         // No one wants to see a KeyValuePair displayed in a GridColumn,
         // so we display the Value instead.
         ColumnDescriptor = columnDescriptor.ResolveChild("Value");
     }
     if (ColumnDescriptor == null)
     {
         ColumnDescriptor = columnDescriptor;
     }
     else
     {
         ColumnDescriptor = ColumnDescriptor.SetCaption(columnDescriptor.Caption);
     }
     IdentifierPath = identifierPath;
 }
Beispiel #12
0
        public IEnumerable <RowNode> GetDescendants(IdentifierPath identifierPath)
        {
            var result = new List <RowNode>();

            foreach (var entry in _children)
            {
                if (!identifierPath.StartsWith(entry.Key))
                {
                    continue;
                }

                if (entry.Key.Equals(identifierPath))
                {
                    result.AddRange(entry.Value);
                    continue;
                }
                foreach (var child in entry.Value)
                {
                    result.AddRange(child.GetDescendants(identifierPath));
                }
            }
            return(result);
        }
Beispiel #13
0
        private ColumnDescriptor GetColumnDescriptor(IDictionary <IdentifierPath, ColumnSpec> columnSpecs, IdentifierPath idPath)
        {
            ColumnDescriptor columnDescriptor;

            if (_columnDescriptors.TryGetValue(idPath, out columnDescriptor))
            {
                return(columnDescriptor);
            }
            var parent = GetColumnDescriptor(columnSpecs, idPath.Parent);

            if (parent == null)
            {
                throw new InvalidOperationException("Could not resolve path " + idPath);
            }
            if (idPath.Name != null)
            {
                columnDescriptor = new ColumnDescriptor(parent, idPath.Name);
            }
            else
            {
                var collectionInfo = DataSchema.GetCollectionInfo(parent.PropertyType);
                if (collectionInfo == null)
                {
                    throw new InvalidOperationException(parent.PropertyType + " is not a collection.");
                }
                columnDescriptor = new ColumnDescriptor(parent, collectionInfo);
            }
            ColumnSpec columnSpec;

            if (columnSpecs.TryGetValue(idPath, out columnSpec))
            {
                columnDescriptor = columnDescriptor.SetColumnSpec(columnSpec);
            }
            _columnDescriptors.Add(idPath, columnDescriptor);
            return(columnDescriptor);
        }
Beispiel #14
0
 public RowKey(RowKey parent, IdentifierPath identifierPath, object value)
 {
     Parent         = parent;
     IdentifierPath = identifierPath;
     Value          = value;
 }