Beispiel #1
0
        public List <NodeColumn> GetColumns(NodeViewOption nodeViewOption)
        {
            LinkedList <NodeColumn> allColumns;

            if ((NodeType == NodeType.Object || NodeType == NodeType.Array) && IsSimple(nodeViewOption))
            {
                allColumns = new LinkedList <NodeColumn>();
                allColumns.AddLast(new NodeColumn
                {
                    Name     = GetDisplayName(),
                    NodeType = NodeType,
                    Path     = Node.ToOne(GetPath()),
                });
            }
            else
            {
                allColumns = new LinkedList <NodeColumn>(GetColumnsForCurrentLevel(true, nodeViewOption));
            }

            var currentSchema = Parent;

            while (currentSchema != null)
            {
                var currentColumns = currentSchema.GetColumnsForCurrentLevel(false, nodeViewOption);
                for (var i = currentColumns.Count - 1; i >= 0; --i)
                {
                    allColumns.AddFirst(currentColumns[i]);
                }

                currentSchema = currentSchema.Parent;
            }

            return(allColumns.ToList());
        }
Beispiel #2
0
 private List <string> GetValues(NodeViewOption nodeViewOption)
 {
     if (NodeUtility.IsPoint(this) &&
         nodeViewOption.ShowGlobalPoint &&
         Parent != null && !NodeUtility.IsCoordinateSystem(Parent as ObjectNode))
     {
         try
         {
             var matrix3D = Matrix3D.Identity;
             var current  = Parent as ObjectNode;
             while (current != null)
             {
                 if (current.Nodes.FirstOrDefault(n => NodeUtility.IsCoordinateSystem(n as ObjectNode)) is ObjectNode coodinateSystemNode)
                 {
                     var coordinateSystem = NodeUtility.CoordinateSystemConvertFromObjectNode(coodinateSystemNode);
                     matrix3D *= coordinateSystem.TransformationMatrixTo();
                 }
                 current = current.Parent as ObjectNode;
             }
             var point = NodeUtility.Point3DConvertFromObjectNode(this) * matrix3D;
             return(new List <string>
             {
                 point.X.ToString(),
                 point.Y.ToString(),
                 point.Z.ToString()
             });
         }
         catch (Exception)
         {
         }
     }
     return(Nodes.Select(n => (n as ValueNode).Value).ToList());
 }
Beispiel #3
0
        public List <string> GetColumns(NodeViewOption nodeViewOption)
        {
            var columns = new List <string>();

            if (nodeRows.Count == 1)
            {
                return(new List <string> {
                    "<Field>", "<Value>"
                });
            }
            else
            {
                if (nodeColumns.Count == 0)
                {
                    return(columns);
                }
                var maxLevel = nodeColumns.Max(c => c.Name.Count(ch => ch == '.'));
                foreach (var nodeColumn in nodeColumns)
                {
                    var columnName = GetColumnName(nodeColumn);
                    if (!nodeViewOption.HideColumns.Contains(columnName))
                    {
                        columns.Add(columnName);
                    }
                }
            }
            return(columns);
        }
Beispiel #4
0
        public void BuildView(Schema schema, RootNode rootNode, NodeViewOption nodeViewOption)
        {
            nodeColumns = schema.GetColumns(nodeViewOption);

            var nodes = rootNode.GetNodes(schema);

            nodeRows = new List <Dictionary <string, string> >();
            foreach (var node in nodes)
            {
                var nodeRow    = new Dictionary <string, string>();
                var firstLevel = true;

                ObjectNode objectNode;
                if (node.NodeType != NodeType.Object &&
                    node.NodeType != NodeType.Array)
                {
                    objectNode = node.Parent as ObjectNode;
                }
                else
                {
                    objectNode = node as ObjectNode;
                }

                while (objectNode != null)
                {
                    if (firstLevel && objectNode.NodeType == NodeType.Object &&
                        objectNode.IsSimple(nodeViewOption))
                    {
                        nodeRow[Node.ToOne(objectNode.GetPath())] = objectNode.DisplayValue(nodeViewOption);
                    }
                    else
                    {
                        foreach (var subNode in objectNode.Nodes
                                 .Where(n => n.NodeType != NodeType.Array &&
                                        n.NodeType != NodeType.Object ||
                                        n.NodeType != NodeType.Array && (n as ObjectNode).IsSimple(nodeViewOption)))
                        {
                            if (!firstLevel && !nodeViewOption.RetainedColumns.Contains(subNode.Name))
                            {
                                continue;
                            }
                            nodeRow[Node.ToOne(subNode.GetPath())] = subNode.DisplayValue(nodeViewOption);
                        }
                    }
                    objectNode = objectNode.Parent as ObjectNode;
                    firstLevel = false;
                }

                nodeRows.Add(nodeRow);
            }
        }
Beispiel #5
0
        public List <List <string> > GetRows(NodeViewOption nodeViewOption)
        {
            var rows = new List <List <string> >();

            if (nodeRows.Count == 1)
            {
                var nodeRow = nodeRows[0];
                foreach (var nodeColumn in nodeColumns)
                {
                    var columnName = GetColumnName(nodeColumn);
                    if (!nodeViewOption.HideColumns.Contains(columnName))
                    {
                        var text = nodeRow.ContainsKey(nodeColumn.Path) ? nodeRow[nodeColumn.Path] : "<null>";
                        if (!IsFiltered(text))
                        {
                            continue;
                        }
                        var row = new List <string>
                        {
                            columnName,
                            text,
                        };
                        rows.Add(row);
                    }
                }
            }
            else
            {
                foreach (var nodeRow in nodeRows)
                {
                    var row = new List <string>();
                    foreach (var nodeColumn in nodeColumns)
                    {
                        var columnName = GetColumnName(nodeColumn);
                        if (!nodeViewOption.HideColumns.Contains(columnName))
                        {
                            nodeRow.TryGetValue(nodeColumn.Path, out var value);
                            var text = value ?? "<null>";
                            row.Add(text);
                        }
                    }

                    if (row.Any(t => IsFiltered(t)))
                    {
                        rows.Add(row);
                    }
                }
            }
            return(rows);
        }
Beispiel #6
0
        public string GetString(NodeViewOption nodeViewOption)
        {
            var nodeValues = GetValues(nodeViewOption);
            var value      = "{ ";

            for (var i = 0; i < Nodes.Count; ++i)
            {
                var node      = Nodes[i];
                var nodeValue = node.Name + ": " + nodeValues[i];
                if (i == 0)
                {
                    value += nodeValue;
                }
                else
                {
                    value += ", " + nodeValue;
                }
            }
            value += " }";
            return(value);
        }
Beispiel #7
0
        private List <NodeColumn> GetColumnsForCurrentLevel(bool firstLevel, NodeViewOption nodeViewOption)
        {
            var columns = new List <NodeColumn>();

            foreach (var subSchema in SubSchemas
                     .Where(s => s.NodeType != NodeType.Object &&
                            s.NodeType != NodeType.Array ||
                            s.NodeType != NodeType.Array && s.IsSimple(nodeViewOption)))
            {
                if (!firstLevel && !nodeViewOption.RetainedColumns.Contains(subSchema.Name))
                {
                    continue;
                }
                columns.Add(new NodeColumn
                {
                    Name     = subSchema.GetDisplayName(),
                    NodeType = subSchema.NodeType,
                    Path     = Node.ToOne(subSchema.GetPath()),
                });
            }

            return(columns);
        }
Beispiel #8
0
 public override string DisplayValue(NodeViewOption nodeViewOption)
 {
     return("<array>");
 }
Beispiel #9
0
 public abstract string DisplayValue(NodeViewOption nodeViewOption);
Beispiel #10
0
 public override string DisplayValue(NodeViewOption nodeViewOption)
 {
     return(Parent != null && Parent.NodeType == NodeType.Array
         ? (Parent as ObjectNode).GetString(nodeViewOption) : "<null>");
 }
Beispiel #11
0
 public bool IsSimple(NodeViewOption nodeViewOption)
 {
     return(SubSchemas.Count <= nodeViewOption.SimpleCount &&
            SubSchemas.All(s => s.NodeType == NodeType.Value));
 }
Beispiel #12
0
 public bool IsSimple(NodeViewOption nodeViewOption)
 {
     return(Nodes.Count <= nodeViewOption.SimpleCount &&
            Nodes.All(n => n.NodeType == NodeType.Value));
 }
Beispiel #13
0
 public override string DisplayValue(NodeViewOption nodeViewOption)
 {
     return(IsSimple(nodeViewOption) ? GetString(nodeViewOption) : "<object>");
 }