public override async Task <NodeService> GetAccount(string accountName) { NodeService account = new NodeService(accountName, _userName, _userPassword, _endpoint, ApiTypes.atAtomPub); NodeCollections blogs = await GetBlogs(); foreach (var item in blogs.Children) { item.Parent = account; account.Children.Add(item); } account.Expanded = true; return(account); }
public override async Task <NodeCollections> GetBlogs() { NodeCollections blogs = new NodeCollections(); var HTTPResponseMessage = await _HTTPConn.Client.GetAsync(_endpoint); if (HTTPResponseMessage.IsSuccessStatusCode) { string s = await HTTPResponseMessage.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine("GET blogs(collection): " + s); /* * <?xml version="1.0" encoding="utf-8"?> * <service xmlns="http://www.w3.org/2007/app"> * <workspace> * <atom:title xmlns:atom="http://www.w3.org/2005/Atom">hoge</atom:title> * <collection href="https://127.0.0.1/atom/entry"> * <atom:title xmlns:atom="http://www.w3.org/2005/Atom">fuga</atom:title> * <accept>application/atom+xml;type=entry</accept> * </collection> * </workspace> * </service> */ XmlDocument xdoc = new XmlDocument(); try { xdoc.LoadXml(s); } catch (Exception e) { // TODO: System.Diagnostics.Debug.WriteLine("LoadXml failed: " + e.Message); return(blogs); } XmlNamespaceManager atomNsMgr = new XmlNamespaceManager(xdoc.NameTable); atomNsMgr.AddNamespace("atom", "http://www.w3.org/2005/Atom"); atomNsMgr.AddNamespace("app", "http://www.w3.org/2007/app"); XmlNodeList workspaceList; workspaceList = xdoc.SelectNodes("//app:service/app:workspace", atomNsMgr); if (workspaceList == null) { return(blogs); } foreach (XmlNode n in workspaceList) { XmlNode accountTitle = n.SelectSingleNode("atom:title", atomNsMgr); if (accountTitle == null) { System.Diagnostics.Debug.WriteLine("atom:title is null. "); continue; } NodeCollection blog = new NodeCollection(accountTitle.InnerText); NodeEntries entries = GetEntryNodesFromXML(n, atomNsMgr); foreach (var item in entries.Children) { item.Parent = blog; blog.Children.Add(item); } blog.Expanded = true; blogs.Children.Add(blog); blogs.Expanded = true; } } return(blogs); }
public override async Task <NodeCollections> GetBlogs() { NodeCollections blogs = new NodeCollections(); return(blogs); }