3 namespace CPE.App.Web.Connect {
6 /// Represents a common-info object returned from Connect.
8 public class CommonInfo {
11 /// The hostname of the Connect service.
13 public string Host { get; private set; }
16 /// The AccountID of the host of the Connect service.
18 public int AccountId { get; private set; }
21 /// The session cookie value for the current request.
23 public string Cookie { get; private set; }
26 /// Returns whether the request is logged in and authenticated with Connect.
28 public bool IsAuthenticated { get { return User.UserId.HasValue; } }
31 /// Contains the user account information if a user is logged into Connect.
33 public UserInfo User { get; private set; }
36 /// Initializes the object by parsing the values from the XmlDocument.
38 /// <param name="document">The XmlDocument returned from Connect for this object.</param>
39 public CommonInfo(XmlNode document) {
42 XmlNode common = document.SelectSingleNode("/results/common");
45 Host = common["host"].InnerText;
46 AccountId = int.Parse(common["account"].Attributes["account-id"].Value);
47 Cookie = common["cookie"].InnerText;
50 User = new UserInfo();
52 if(common["user"] != null) {
53 User.UserId = int.Parse(common["user"].Attributes["user-id"].Value);
54 User.Name = common["user"].SelectSingleNode("name").InnerText;
55 User.Login = common["user"].SelectSingleNode("login").InnerText;
60 /// Contains the current user information if logged into the service.
62 public class UserInfo {
65 /// The UserID of the user.
67 public int? UserId { get; internal set; }
70 /// The full name of the user.
72 public string Name { get; internal set; }
75 /// The login of the user.
77 public string Login { get; internal set; }