public VK.PageStatus Get(VK.UID page) #endif { // Check HostSession.EnsureHasPermission(VK.SecurityFlag.Statuses); if (!page.IsValid) throw new ArgumentException("Invalid UID specified: " + page.Value); // Request var args = new NameValueCollection(); args.Add("user_id", page.ToString()); #if NEWSTYLE XmlElement response = await HostSession.Network.AsyncXmlMethodCall("status.get", args); #else XmlElement response = HostSession.Network.XmlMethodCall("status.get", args); #endif // Check if (response == null || response["text"] == null) throw new VK.APIImplException(HostSession, "status.get", "Unexpected server reply."); // Parse var status = new VK.PageStatus(); status.Parse(response); // Done return status; }
GetAlbums(VK.UID page, int offset, uint count) { // Check HostSession.EnsureHasPermission(VK.SecurityFlag.Audios); if (!page.IsValid) throw new ArgumentException("Invalid page UID specified."); else if (count < 1 || count > 100) throw new ArgumentOutOfRangeException("count", "Count of albums to fetch per one request must be in range [1-100]."); else if (offset < -1) throw new ArgumentOutOfRangeException("offset", "Invalid 'offset' value."); // Request var args = new NameValueCollection(); args.Add("owner_id", page.ToString()); if (offset != -1) args.Add("offset", offset.ToString()); args.Add("count", count.ToString()); #if NEWSTYLE XmlElement response = await HostSession.Network.AsyncXmlMethodCall("audio.getAlbums", args); #else XmlElement response = HostSession.Network.XmlMethodCall("audio.getAlbums", args); #endif // Check if (response == null) throw new VK.APIImplException(HostSession, "audio.getAlbums", "Unexpected server reply."); uint totalCount = 0; // Parse VK.AudioAlbum[] albums = null; if (response.GetAttribute("list") == "true") // Notice: maybe this is incorrect, but currently okay { int iCount = 0; foreach (XmlElement node in response.ChildNodes) { // Ensure it is what we expect if (iCount == 0 && node.Name == "count") { // We have totalCount totalCount = uint.Parse(node.InnerText); if (count <= 0 || count > totalCount) count = totalCount; albums = new VK.AudioAlbum[count]; continue; } else if (node.Name != "album") throw new NotSupportedException("Unknown node in xml server reply; expected 'album', got '" + node.Name + "'."); albums[iCount++].Parse(node); } } // Done return new ArraySegment<VK.AudioAlbum,uint>(albums, totalCount); }