Пример #1
0
        private static bool Remove(IMdxElement mdxElement, HashSet <IMdxElement> deleteNodes)
        {
            if (deleteNodes.Contains(mdxElement))
            {
                return(true);
            }

            var result = false;

            var children = mdxElement
                           .GetChildren()
                           .ToArray();

            foreach (var child in children)
            {
                var removeFromChild = Remove(child, deleteNodes);

                if (removeFromChild)
                {
                    var mdxCollection = mdxElement as IMdxCollectionElements;

                    if (mdxCollection != null)
                    {
                        mdxCollection.RemoveChild(child);

                        removeFromChild = mdxCollection.IsEmpty();
                    }
                }

                result = removeFromChild || result;
            }

            return(result);
        }
Пример #2
0
        private static List <MdxValueElement> GetMdxValueElements(IMdxElement initWhere)
        {
            var wheres = new List <MdxValueElement>();

            if (initWhere.GetType() == typeof(MdxValueElement))
            {
                wheres.Add((MdxValueElement)initWhere);

                return(wheres);
            }

            if (initWhere.GetType() == typeof(TypedMdxElement))
            {
                var initWhereChildren = initWhere.GetChildren()
                                        .Where(el => el.GetType() == typeof(MdxValueElement))
                                        .ToArray();

                wheres.AddRange(initWhereChildren.Cast <MdxValueElement>());
            }
            return(wheres);
        }