|
using System;
using System.Runtime.Serialization;
// Namespace does not match code / folder hierarchy as I wanted it to reflect the facebook structure
namespace Facebook.users
{
/// <summary>
/// Type that can be serialised from JSON to a .net class
/// http://wiki.developers.facebook.com/index.php/Users.getInfo
/// </summary>
[DataContract]
public class getInfo
{
[DataMember]
public string first_name { get; set; }
[DataMember]
public string last_name { get; set; }
[IgnoreDataMember] // Marked as ignore as it is not to be populated from the facebook lookup(i.e. not a facebook field)
public string full_name { get { return String.Format("{0} {1}", first_name, last_name); } }
[DataMember]
public string pic_big { get; set; }
[DataMember]
public string pic_small { get; set; }
[DataMember]
public string profile_url { get; set; }
[DataMember]
public hs_info hs_info { get; set; }
[DataMember]
public hometown_location hometown_location { get; set; }
[DataMember]
public status status { get; set; }
}
/// <summary>
/// High School Info
/// </summary>
[DataContract]
public class hs_info
{
[DataMember]
public string hs1_name { get; set; }
[DataMember]
public string hs2_name { get; set; }
[DataMember]
public string grad_year { get; set; }
[DataMember]
public string hs1_id { get; set; }
[DataMember]
public string hs2_id { get; set; }
}
/// <summary>
/// "Hometown" profile fields. Contains three children: city, state, and country.
/// </summary>
[DataContract]
public class hometown_location
{
[DataMember]
public string city { get; set; }
[DataMember]
public string state { get; set; }
[DataMember]
public string country { get; set; }
}
/// <summary>
/// The user's facebook status
/// </summary>
[DataContract]
public class status
{
[DataMember]
public string message { get; set; }
[DataMember]
public double time { get; set; }
// Property to return the time in a .net friendly datetime instead of the unix EPOC time
[IgnoreDataMember] // Marked as ignore as it is not to be populated from the facebook lookup(i.e. not a facebook field)
public DateTime time_DateTime { get { return Facebook.Helpers.ConvertUnixTimestampToDotNet(time); } }
[DataMember]
public string status_id { get; set; }
// Property to return a full string of all the status elements
[IgnoreDataMember] // Marked as ignore as it is not to be populated from the facebook lookup(i.e. not a facebook field)
public string status_line
{
get
{
if (time != 0) // only format and return a status if there is one, otherwise return "not set".
return (String.Format("{0} (Set on: {1} at {2})", message, time_DateTime.ToLongDateString(), time_DateTime.ToLongTimeString()));
else
return "Not set";
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.