OSDN Git Service

フォトライフへの投稿に成功。疲れた。WsseAtomConnectionの試行錯誤の結果。
[futonwriter/old_trunk.git] / HatenaDiaryClient / Models / Hatena / FotolifeEntry.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Xml.Linq;
6 using System.Text.RegularExpressions;
7
8 namespace Azyobuzi.HatenaDiaryClient.Models.Hatena
9 {
10     public class FotolifeEntry
11     {
12         public string Title { set; get; }
13         public string PageUri { set; get; }
14         public string Id { set; get; }
15         public DateTime Issued { set; get; }
16         public string Folder { set; get; }
17         public string ImageUri { set; get; }
18         public string ThumbnailUri { set; get; }
19         public string HatenaSyntax { set; get; }
20
21         public FotolifeEntry() { }
22         public FotolifeEntry(XElement xml, bool isRdf)
23         {
24             if (isRdf)
25             {
26                 //TODO
27             }
28             else
29             {
30                 this.Title = xml.Element(XmlNamespaces.Atom02Spec + "title").Value;
31                 this.PageUri = xml.Elements(XmlNamespaces.Atom02Spec + "link")
32                     .Where(_ => _.Attribute("rel").Value == "alternate")
33                     .Select(_ => _.Attribute("href").Value)
34                     .FirstOrDefault();
35                 this.Id = Regex.Match(this.PageUri, @"\d+$").ToString();
36                 this.Issued = DateTime.Parse(xml.Element(XmlNamespaces.Atom02Spec + "issued").Value);
37                 this.Folder = xml.Element(XmlNamespaces.DublinCore + "subject").Value;
38                 this.ImageUri = xml.Element(XmlNamespaces.HatenaNs + "imageurl").Value;
39                 this.ThumbnailUri = xml.Element(XmlNamespaces.HatenaNs + "imageurlsmall").Value;
40                 this.HatenaSyntax = xml.Element(XmlNamespaces.HatenaNs + "syntax").Value;
41             }
42         }
43     }
44 }