FromString() public static method

public static FromString ( string name ) : SizeAndOrientation
name string
return SizeAndOrientation
Ejemplo n.º 1
0
        public static Layout FromDom(HtmlDom dom, Layout defaultIfMissing)
        {
            var firstPage = dom.SelectSingleNode("descendant-or-self::div[contains(@class,'bloom-page')]");

            if (firstPage == null)
            {
                return(defaultIfMissing);
            }

            var layout = new Layout {
                SizeAndOrientation = defaultIfMissing.SizeAndOrientation, Style = defaultIfMissing.Style
            };

            foreach (var part in firstPage.GetStringAttribute("class").SplitTrimmed(' '))
            {
                if (part.ToLowerInvariant().Contains("portrait") || part.ToLowerInvariant().Contains("landscape"))
                {
                    layout.SizeAndOrientation = SizeAndOrientation.FromString(part);
                }
                if (part.ToLowerInvariant().Contains("layout-style-"))
                {
                    int startIndex = "layout-style-".Length;
                    layout.Style = part.Substring(startIndex, part.Length - startIndex);                        //reivew: this might let us suck up a style that is no longer listed in any css
                }
            }
            return(layout);
        }
Ejemplo n.º 2
0
        public static Layout FromPage(XmlElement page, Layout layout)
        {
            foreach (var part in page.GetStringAttribute("class").SplitTrimmed(' '))
            {
                if (part.ToLowerInvariant().Contains("portrait") || part.ToLowerInvariant().Contains("landscape"))
                {
                    layout.SizeAndOrientation = SizeAndOrientation.FromString(part);
                }

                if (part.ToLowerInvariant().Contains("layout-style-"))
                {
                    int startIndex = "layout-style-".Length;
                    layout.Style =
                        part.Substring(startIndex,
                                       part.Length -
                                       startIndex);                  //reivew: this might let us suck up a style that is no longer listed in any css
                }
            }

            return(layout);
        }