Git Repository Public Repository

CPE_learningsite

URLs

Copy to Clipboard

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
using System.Xml;

namespace CPE.App.Web.Connect {

	/// <summary>
	/// Represents a common-info object returned from Connect.
	/// </summary>
	public class CommonInfo {

		/// <summary>
		/// The hostname of the Connect service.
		/// </summary>
		public string Host { get; private set; }

		/// <summary>
		/// The AccountID of the host of the Connect service.
		/// </summary>
		public int AccountId { get; private set; }

		/// <summary>
		/// The session cookie value for the current request.
		/// </summary>
		public string Cookie { get; private set; }

		/// <summary>
		/// Returns whether the request is logged in and authenticated with Connect.
		/// </summary>
		public bool IsAuthenticated { get { return User.UserId.HasValue; } }

		/// <summary>
		/// Contains the user account information if a user is logged into Connect.
		/// </summary>
		public UserInfo User { get; private set; }

		/// <summary>
		/// Initializes the object by parsing the values from the XmlDocument.
		/// </summary>
		/// <param name="document">The XmlDocument returned from Connect for this object.</param>
		public CommonInfo(XmlNode document) {

			// Find main node
			XmlNode common = document.SelectSingleNode("/results/common");

			// Parse values	
			Host = common["host"].InnerText;
			AccountId = int.Parse(common["account"].Attributes["account-id"].Value);
			Cookie = common["cookie"].InnerText;

			// Blank user
			User = new UserInfo();
		
			if(common["user"] != null) {
				User.UserId = int.Parse(common["user"].Attributes["user-id"].Value);
				User.Name = common["user"].SelectSingleNode("name").InnerText;
				User.Login = common["user"].SelectSingleNode("login").InnerText;
			}
		}

		/// <summary>
		/// Contains the current user information if logged into the service.
		/// </summary>
		public class UserInfo {

			/// <summary>
			/// The UserID of the user.
			/// </summary>
			public int? UserId { get; internal set; }

			/// <summary>
			/// The full name of the user.
			/// </summary>
			public string Name { get; internal set; }

			/// <summary>
			/// The login of the user.
			/// </summary>
			public string Login { get; internal set; }
		}
	}
}

Commits for CPE_learningsite/CPE/CPE.App/CPE.App.Web/Connect/CommonInfo.cs

Diff revisions: vs.
Revision Author Commited Message
4cd176 ... v.shishlov Fri 27 Aug, 2021 14:33:17 +0000

initial commit