1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
using System;
using System.Xml;
namespace FlickrNet
{
/// <summary>
/// Parent object containing details of a photos comments.
/// </summary>
internal class PhotoComments
{
static private string _photoId;
static private Comment[] _comments;
static internal Comment[] GetComments(XmlNode node)
{
if( node.Attributes["photo_id"] != null )
_photoId = node.Attributes["photo_id"].Value;
XmlNodeList nodes = node.SelectNodes("comment");
_comments = new Comment[nodes.Count];
for(int i = 0; i < _comments.Length; i++)
{
_comments[i] = new Comment(_photoId, nodes[i]);
}
return _comments;
}
}
/// <summary>
/// Contains the details of a comment made on a photo.
/// returned by the <see cref="Flickr.PhotosCommentsGetList"/> method.
/// </summary>
public class Comment
{
private string _photoId;
private string _authorUserId;
private string _authorUserName;
private string _commentId;
private Uri _permaLink;
private DateTime _dateCreated;
private string _comment;
/// <summary>
/// The photo id associated with this comment.
/// </summary>
public string PhotoId
{
get { return _photoId; }
}
/// <summary>
/// The comment id of this comment.
/// </summary>
public string CommentId
{
get { return _commentId; }
}
/// <summary>
/// The user id of the author of the comment.
/// </summary>
public string AuthorUserId
{
get { return _authorUserId; }
}
/// <summary>
/// The username (screen name) of the author of the comment.
/// </summary>
public string AuthorUserName
{
get { return _authorUserName; }
}
/// <summary>
/// The permalink to the comment on the photos web page.
/// </summary>
public Uri Permalink
{
get { return _permaLink; }
}
/// <summary>
/// The date and time that the comment was created.
/// </summary>
public DateTime DateCreated
{
get { return _dateCreated; }
}
/// <summary>
/// The comment text (can contain HTML).
/// </summary>
public string CommentHtml
{
get { return _comment; }
}
internal Comment(string photoId, XmlNode node)
{
_photoId = photoId;
if( node.Attributes["id"] != null )
_commentId = node.Attributes["id"].Value;
if( node.Attributes["author"] != null )
_authorUserId = node.Attributes["author"].Value;
if( node.Attributes["authorname"] != null )
_authorUserName = node.Attributes["authorname"].Value;
if( node.Attributes["permalink"] != null )
_permaLink = new Uri(node.Attributes["permalink"].Value);
if( node.Attributes["datecreate"] != null )
_dateCreated = Utils.UnixTimestampToDate(node.Attributes["datecreate"].Value);
if( node.InnerXml.Length > 0 )
_comment = node.InnerText;
}
}
}
|