Beispiel #1
0
 public TOpmlOutline(XElement opmlOutline)
     : this()
 {
     Title = opmlOutline.SafeReadAttribute <string>(XML_ATTRIBUTE_TITLE, "");
     if (opmlOutline.Attributes().Any(x => x.Name == XML_ATTRIBUTE_TYPE))
     {
         OutlineType = opmlOutline.SafeReadAttribute <string>(XML_ATTRIBUTE_TYPE, XML_DEFAULT_TYPE);
     }
     if (OutlineType == "rss")
     {
         Description = opmlOutline.SafeReadAttribute <string>(XML_ATTRIBUTE_DESCRIPTION, "");
         XmlUrl      = new Uri(opmlOutline.SafeReadAttribute <string>(XML_ATTRIBUTE_XML_URL, XML_DEFAULT_XML_URL));
         string HtmlUrlAttribute = opmlOutline.SafeReadAttribute <string>(XML_ATTRIBUTE_HTML_URL, XML_DEFAULT_HTML_URL);
         HtmlUrl  = new Uri(HtmlUrlAttribute == "" ? XML_DEFAULT_HTML_URL : HtmlUrlAttribute);
         Outlines = new TOpmlOutlineCollection();
     }
     else
     {
         Description = "";
         XmlUrl      = new Uri(XML_DEFAULT_XML_URL);
         HtmlUrl     = new Uri(XML_DEFAULT_HTML_URL);
         if (opmlOutline.Elements(XML_THIS_ELEMENT).Count() > 0)
         {
             Outlines = new TOpmlOutlineCollection(opmlOutline.Elements(XML_THIS_ELEMENT));
         }
         else
         {
             Outlines = new TOpmlOutlineCollection();
         }
     }
 }
Beispiel #2
0
        public bool Load(string filename)
        {
            #region === Validate parameters ===
            if (string.IsNullOrWhiteSpace(filename))
            {
                Trace.WriteLine("Unable to open an null or empty filename");
                return(false);
            }

            if (!File.Exists(filename))
            {
                Trace.WriteLine(string.Format("filename is missing or access is denied : {0}", filename));
                return(false);
            }
            #endregion === Validate parameters ===

            Name = filename;
            try {
                XDocument SourceDocument = XDocument.Load(filename);
                Title    = SourceDocument.Element(XML_THIS_ELEMENT).Element("head").Element("title").Value;
                Outlines = new TOpmlOutlineCollection(SourceDocument.Element(XML_THIS_ELEMENT).Element("body").Elements(TOpmlOutline.XML_THIS_ELEMENT));
            } catch (Exception ex) {
                Trace.WriteLine(string.Format("Unable to read or parse XML document : {0} : {1}", filename, ex.Message));
            }
            return(true);
        }
 public TOpmlOutlineCollection(TOpmlOutlineCollection opmlOutlines)
 {
     foreach (TOpmlOutline OpmlOutlineItem in opmlOutlines)
     {
         this.Add(new TOpmlOutline(OpmlOutlineItem));
     }
 }
Beispiel #4
0
 public TOpmlOutline()
 {
     OutlineType = XML_DEFAULT_TYPE;
     Title       = "";
     Description = "";
     XmlUrl      = new Uri(XML_DEFAULT_XML_URL);
     HtmlUrl     = new Uri(XML_DEFAULT_HTML_URL);
     Outlines    = new TOpmlOutlineCollection();
 }
Beispiel #5
0
 public TOpmlOutline(TOpmlOutline opmlOutline)
     : this()
 {
     OutlineType = opmlOutline.OutlineType;
     Title       = opmlOutline.Title;
     Description = opmlOutline.Description;
     XmlUrl      = new Uri(opmlOutline.XmlUrl.ToString());
     HtmlUrl     = new Uri(opmlOutline.HtmlUrl.ToString());
     Outlines    = new TOpmlOutlineCollection(opmlOutline.Outlines);
 }
Beispiel #6
0
 public TOpmlDocument(TOpmlDocument document)
 {
     Name     = document.Name;
     Title    = document.Title;
     Outlines = new TOpmlOutlineCollection(document.Outlines);
 }
Beispiel #7
0
 public TOpmlDocument()
 {
     Name     = "";
     Title    = "";
     Outlines = new TOpmlOutlineCollection();
 }