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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
using System;
using System.Xml.Serialization;
using System.Xml.Schema;
namespace FlickrNet
{
/// <summary>
/// The <see cref="Person"/> class contains details returned by the <see cref="Flickr.PeopleGetInfo"/>
/// method.
/// </summary>
[System.Serializable]
[XmlRoot("person")]
public class Person
{
internal static Person SerializePerson(System.Xml.XmlNode node)
{
Person p = (Person)Utils.Deserialize(node, typeof(Person));
return p;
}
private string _userId;
private int _isAdmin;
private int _isPro;
private int _iconServer;
private int _iconFarm;
private string _username;
private string _realname;
private string _location;
private PersonPhotosSummary _summary = new PersonPhotosSummary();
private string _photosUrl;
private string _profileUrl;
private string _mboxHash;
/// <summary>The user id of the user.</summary>
/// <remarks/>
[XmlAttribute("nsid", Form=XmlSchemaForm.Unqualified)]
public string UserId { get { return _userId; } set { _userId = value; } }
/// <summary>Is the user an administrator.
/// 1 = admin, 0 = normal user.</summary>
/// <remarks></remarks>
[XmlAttribute("isadmin", Form=XmlSchemaForm.Unqualified)]
public int IsAdmin { get { return _isAdmin; } set { _isAdmin = value; } }
/// <summary>Does the user posses a pro account.
/// 0 = free acouunt, 1 = pro account holder.</summary>
[XmlAttribute("ispro", Form=XmlSchemaForm.Unqualified)]
public int IsPro { get { return _isPro; } set { _isPro = value; } }
/// <summary>Does the user posses a pro account.
/// 0 = free acouunt, 1 = pro account holder.</summary>
[XmlAttribute("iconserver", Form=XmlSchemaForm.Unqualified)]
public int IconServer { get { return _iconServer; } set { _iconServer = value; } }
/// <summary>No idea what purpose this field serves.</summary>
[XmlAttribute("iconfarm", Form=XmlSchemaForm.Unqualified)]
public int IconFarm { get { return _iconFarm; } set { _iconFarm = value; } }
/// <summary>The users username, also known as their screenname.</summary>
[XmlElement("username", Form=XmlSchemaForm.Unqualified)]
public string UserName { get { return _username; } set { _username = value; } }
/// <summary>The users real name, as entered in their profile.</summary>
[XmlElement("realname", Form=XmlSchemaForm.Unqualified)]
public string RealName { get { return _realname; } set { _realname = value; } }
/// <summary>The SHA1 hash of the users email address - used for FOAF networking.</summary>
[XmlElement("mbox_sha1sum", Form=XmlSchemaForm.Unqualified)]
public string MailBoxSha1Hash { get { return _mboxHash; } set { _mboxHash = value; } }
/// <summary>Consists of your current location followed by country.</summary>
/// <example>e.g. Newcastle, UK.</example>
[XmlElement("location", Form=XmlSchemaForm.Unqualified)]
public string Location { get { return _location; } set { _location = value; } }
/// <summary>Sub element containing a summary of the users photo information.</summary>
/// <remarks/>
[XmlElement("photos", Form=XmlSchemaForm.Unqualified)]
public PersonPhotosSummary PhotosSummary { get { return _summary; } set { _summary = value; } }
/// <summary>
/// The users photo location on Flickr
/// http://www.flickr.com/photos/username/
/// </summary>
[XmlElement("photosurl",Form=XmlSchemaForm.Unqualified)]
public string PhotosUrl { get { return _photosUrl; } set { _photosUrl = value; } }
/// <summary>
/// The users profile location on Flickr
/// http://www.flickr.com/people/username/
/// </summary>
[XmlElement("profileurl",Form=XmlSchemaForm.Unqualified)]
public string ProfileUrl { get { return _profileUrl; } set { _profileUrl = value; } }
/// <summary>
/// Returns the <see cref="Uri"/> for the users Buddy Icon.
/// </summary>
[XmlIgnore()]
public Uri BuddyIconUrl
{
get
{
if( IconServer == 0 )
return new Uri("http://www.flickr.com/images/buddyicon.jpg");
else
return new Uri(String.Format("http://static.flickr.com/{0}/buddyicons/{1}.jpg", IconServer, UserId));
}
}
}
/// <summary>
/// A summary of a users photos.
/// </summary>
[System.Serializable]
public class PersonPhotosSummary
{
private int _photoCount;
private int _views;
/// <summary>The first date the user uploaded a picture, converted into <see cref="DateTime"/> format.</summary>
[XmlIgnore()]
public DateTime FirstDate
{
get { return Utils.UnixTimestampToDate(firstdate_raw); }
}
/// <summary>The first date the user took a picture, converted into <see cref="DateTime"/> format.</summary>
[XmlIgnore()]
public DateTime FirstTakenDate
{
get
{
if( firsttakendate_raw == null || firsttakendate_raw.Length == 0 ) return DateTime.MinValue;
return System.DateTime.Parse(firsttakendate_raw);
}
}
/// <summary>The total number of photos for the user.</summary>
/// <remarks/>
[XmlElement("count", Form=XmlSchemaForm.Unqualified)]
public int PhotoCount
{
get { return _photoCount; }
set { _photoCount = value; }
}
/// <summary>The total number of photos for the user.</summary>
/// <remarks/>
[XmlElement("views", Form=XmlSchemaForm.Unqualified)]
public int Views
{
get { return _views; }
set { _views = value; }
}
/// <remarks>The unix timestamp of the date the first photo was uploaded.</remarks>
[XmlElement("firstdate", Form=XmlSchemaForm.Unqualified)]
public string firstdate_raw;
/// <remarks>The date the first photo was taken.</remarks>
[XmlElement("firsttakendate", Form=XmlSchemaForm.Unqualified)]
public string firsttakendate_raw;
}
}
|