private CubeMetadata BuildFakeMetadata()
        {
            var metadata = new CubeMetadata();

            var p = new Perspective("p");

            var mg = new MeasureGroup("mg");

            var h1 = new Hierarchy("[h1]", "h1", "df");
            var h2 = new Hierarchy("[h2]", "h2", "df");

            var hs = new HierarchyCollection();

            hs.Add(h1);
            hs.Add(h2);

            var d = new Dimension("[d]", "d", hs);

            mg.LinkedDimensions.Add(d);

            var m1 = new Measure("[m1]", "m1", "df");
            var m2 = new Measure("[m2]", "m2", "df");

            mg.Measures.Add(m1);
            mg.Measures.Add(m2);

            p.MeasureGroups.Add(mg);

            metadata.Perspectives.Add(p);
            return(metadata);
        }
        private CubeMetadata BuildFakeMetadata()
        {
            var metadata = new CubeMetadata();

            var p = new Perspective("p");

            var mg = new MeasureGroup("mg");

            var h1 = new Hierarchy("[h1]", "h1", "df");
            var h2 = new Hierarchy("[h2]", "h2", "df");

            var hs = new HierarchyCollection();
            hs.Add(h1);
            hs.Add(h2);

            var d = new Dimension("[d]", "d", hs);
            mg.LinkedDimensions.Add(d);

            var m1 = new Measure("[m1]", "m1", "df");
            var m2 = new Measure("[m2]", "m2", "df");
            mg.Measures.Add(m1);
            mg.Measures.Add(m2);

            p.MeasureGroups.Add(mg);

            metadata.Perspectives.Add(p);
            return metadata;
        }
        public HierarchyCollection <Heading> GetHeadingHierarchy(string html)
        {
            var hierarchy     = new HierarchyCollection <Heading>();
            var headingsStack = new Stack <HierarchyItem <Heading> >();

            foreach (var heading in GetHeadings(html))
            {
                var hiearchyItem = new HierarchyItem <Heading>(heading);

                var addedItem = false;
                while (headingsStack.Count > 0)
                {
                    // Keep looking up the heading hierarchy until we find the
                    // first item that is a higher heading type than the current
                    // heading
                    var parentHeading = headingsStack.Peek();

                    if (parentHeading.Item.HeadingType < heading.HeadingType)
                    {
                        headingsStack.Push(hiearchyItem);
                        parentHeading.Children.Add(hiearchyItem);
                        addedItem = true;
                        break;
                    }
                    headingsStack.Pop();
                }

                if (!addedItem)
                {
                    headingsStack.Push(hiearchyItem);
                    hierarchy.Add(hiearchyItem);
                }
            }

            return(hierarchy);
        }
        public HierarchyCollection<Heading> GetHeadingHierarchy(string html)
        {
            var hierarchy = new HierarchyCollection<Heading>();
            var headingsStack = new Stack<HierarchyItem<Heading>>();

            foreach (var heading in GetHeadings(html))
            {
                var hiearchyItem = new HierarchyItem<Heading>(heading);

                var addedItem = false;
                while (headingsStack.Count > 0)
                {
                    // Keep looking up the heading hierarchy until we find the
                    // first item that is a higher heading type than the current
                    // heading
                    var parentHeading = headingsStack.Peek();
                    if (parentHeading.Item.HeadingType < heading.HeadingType)
                    {
                        headingsStack.Push(hiearchyItem);
                        parentHeading.Children.Add(hiearchyItem);
                        addedItem = true;
                        break;
                    }
                    headingsStack.Pop();
                }

                if (!addedItem)
                {
                    headingsStack.Push(hiearchyItem);
                    hierarchy.Add(hiearchyItem);
                }
            }

            return hierarchy;
        }