Exemplo n.º 1
0
        private static void RemoveDimensionNodeById(IDimensionNode node, int id)
        {
            if (node.DimNodes == null || node.DimNodes.Length == 0)
            {
                return;
            }

            var nodes = node.DimNodes.ToList();

            node.DimNodes = nodes.Where(n => n.DimVal.DimValId.Id != id).ToArray();
            foreach (var dimNode in node.DimNodes)
            {
                RemoveDimensionNodeById(dimNode, id);
            }
        }
Exemplo n.º 2
0
        private static IDimensionNode GetDimensionNodeById(IDimensionNode node, int id)
        {
            if (node.DimVal.DimValId.Id == id)
            {
                return(node);
            }

            if (node.DimNodes == null || node.DimNodes.Length == 0)
            {
                return(null);
            }

            return
                (node.DimNodes.Select(dimNode => GetDimensionNodeById(dimNode, id))
                 .FirstOrDefault(targetNode => targetNode != null));
        }
Exemplo n.º 3
0
        private static IEnumerable <int> ProcessDimensionNode(IDimensionNode dimNode)
        {
            var idList = new HashSet <int> {
                dimNode.DimVal.DimValId.Id
            };

            if (dimNode.DimNodes == null)
            {
                return(idList);
            }

            foreach (var node in dimNode.DimNodes.Where(node => node != null))
            {
                idList.AddRange(ProcessDimensionNode(node));
            }

            return(idList);
        }
Exemplo n.º 4
0
        public void AddDimensionNodeToDimension(IDimensionNode dimensionNodeToAdd,
                                                int dimensionId, int parentDimValId)
        {
            var dimension = GetDimensionById(dimensionId);

            if (dimension == null)
            {
                return;
            }

            var parentNode = GetDimensionNodeById(dimension.DimNode, parentDimValId);

            if (parentNode == null)
            {
                return;
            }

            var nodes = parentNode.DimNodes == null ? new List <IDimensionNode>() : parentNode.DimNodes.ToList();

            nodes.Add(dimensionNodeToAdd);
            parentNode.DimNodes = nodes.ToArray();
        }