public static WPPostItemBuilder WithAuthor(
     this WPPostItemBuilder @this,
     WPAuthor author)
 {
     return(@this.As <IWPPostItemBuilder>()
            .WithAuthor(author));
 }
예제 #2
0
        public static List <WPAuthor> ImportAuthors(string fileLocation)
        {
            try
            {
                var nsm = new XmlNamespaceManager(new NameTable());
                nsm.AddNamespace("wp", "http://wordpress.org/export/1.2/excerpt/");
                var parseContext = new XmlParserContext(null, nsm, null, XmlSpace.Default);

                using (var reader = XmlReader.Create(fileLocation, null, parseContext))
                {
                    var    doc = XDocument.Load(reader);
                    string WordpressNamespace = "http://wordpress.org/export/1.2/";

                    XNamespace      wpContent   = WordpressNamespace;
                    List <WPAuthor> blogAuthors = new List <WPAuthor>();

                    foreach (XElement element in doc.Descendants("channel"))
                    {
                        foreach (XElement e in element.Descendants(wpContent + "author"))
                        {
                            WPAuthor auth = new WPAuthor(e);
                            blogAuthors.Add(auth);
                        }
                    }

                    return(blogAuthors);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Failed to import authors: " + ex.Message, "WP Importer");
                return(new List <WPAuthor>());
            }
        }
예제 #3
0
 /// <inheritdoc />
 WPPostItemBuilder IWPPostItemBuilder.WithAuthor(
     WPAuthor author)
 {
     _author = author;
     return(this);
 }
 /// <inheritdoc />
 WPAttachmentItemBuilder IWPAttachmentItemBuilder.WithAuthor(
     WPAuthor author)
 {
     _author = author;
     return(this);
 }