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
|
using System;
using System.Xml;
namespace FlickrNet
{
/// <summary>
/// Contains details of a user
/// </summary>
[System.Serializable]
public class FoundUser
{
private string _userId;
private string _username;
/// <summary>
/// The ID of the found user.
/// </summary>
public string UserId
{
get { return _userId; }
}
/// <summary>
/// The username of the found user.
/// </summary>
public string Username
{
get { return _username; }
}
internal FoundUser(string userId, string username)
{
_userId = userId;
_username = username;
}
internal FoundUser(XmlNode node)
{
if( node.Attributes["nsid"] != null )
_userId = node.Attributes["nsid"].Value;
if( node.Attributes["id"] != null )
_userId = node.Attributes["id"].Value;
if( node.Attributes["username"] != null )
_username = node.Attributes["username"].Value;
if( node.SelectSingleNode("username") != null )
_username = node.SelectSingleNode("username").InnerText;
}
}
/// <summary>
/// The upload status of the user, as returned by <see cref="Flickr.PeopleGetUploadStatus"/>.
/// </summary>
[System.Serializable]
public class UserStatus
{
private bool _isPro;
private string _userId;
private string _username;
private long _bandwidthMax;
private long _bandwidthUsed;
private long _filesizeMax;
internal UserStatus(XmlNode node)
{
if( node == null )
throw new ArgumentNullException("node");
if( node.Attributes["id"] != null )
_userId = node.Attributes["id"].Value;
if( node.Attributes["nsid"] != null )
_userId = node.Attributes["nsid"].Value;
if( node.Attributes["ispro"] != null )
_isPro = node.Attributes["ispro"].Value=="1";
if( node.SelectSingleNode("username") != null )
_username = node.SelectSingleNode("username").InnerText;
XmlNode bandwidth = node.SelectSingleNode("bandwidth");
if( bandwidth != null )
{
_bandwidthMax = Convert.ToInt64(bandwidth.Attributes["max"].Value);
_bandwidthUsed = Convert.ToInt64(bandwidth.Attributes["used"].Value);
}
XmlNode filesize = node.SelectSingleNode("filesize");
if( filesize != null )
{
_filesizeMax = Convert.ToInt64(filesize.Attributes["max"].Value);
}
}
/// <summary>
/// The id of the user object.
/// </summary>
public string UserId
{
get { return _userId; }
}
/// <summary>
/// The Username of the selected user.
/// </summary>
public string UserName
{
get { return _username; }
}
/// <summary>
/// Is the current user a Pro account.
/// </summary>
public bool IsPro
{
get { return _isPro; }
}
/// <summary>
/// The maximum bandwidth (in bytes) that the user can use each month.
/// </summary>
public long BandwidthMax
{
get { return _bandwidthMax; }
}
/// <summary>
/// The number of bytes of the current months bandwidth that the user has used.
/// </summary>
public long BandwidthUsed
{
get { return _bandwidthUsed; }
}
/// <summary>
/// The maximum filesize (in bytes) that the user is allowed to upload.
/// </summary>
public long FilesizeMax
{
get { return _filesizeMax; }
}
/// <summary>
/// <see cref="Double"/> representing the percentage bandwidth used so far. Will range from 0 to 1.
/// </summary>
public Double PercentageUsed
{
get { return BandwidthUsed * 1.0 / BandwidthMax; }
}
}
}
|