@@ -46,29 +46,16 @@ public partial class Session : XenObject<Session>
4646 public const int STANDARD_TIMEOUT = 24 * 60 * 60 * 1000 ;
4747
4848 /// <summary>
49- /// This string is used as the HTTP UserAgent for each request.
49+ /// The default HTTP UserAgent for each request.
5050 /// </summary>
51- public static string UserAgent = $ "XenAPI/{ Helper . APIVersionString ( API_Version . LATEST ) } ";
52-
53- /// <summary>
54- /// If null, no proxy is used, otherwise this proxy is used for each request.
55- /// </summary>
56- public static IWebProxy Proxy = null ;
57-
58- public API_Version APIVersion = API_Version . UNKNOWN ;
59-
60- public object Tag ;
51+ public static readonly string DefaultUserAgent = $ "XenAPI/{ Helper . APIVersionString ( API_Version . LATEST ) } ";
6152
6253 #region Constructors
6354
55+ /// <exception cref="ArgumentNullException">Thrown if 'client' is null</exception>
6456 public Session ( JsonRpcClient client )
6557 {
66- client . Timeout = STANDARD_TIMEOUT ;
67- client . KeepAlive = true ;
68- client . UserAgent = UserAgent ;
69- client . WebProxy = Proxy ;
70- client . AllowAutoRedirect = true ;
71- JsonRpcClient = client ;
58+ JsonRpcClient = client ?? throw new ArgumentNullException ( nameof ( client ) ) ;
7259 }
7360
7461 public Session ( string url ) :
@@ -230,6 +217,19 @@ public override string SaveChanges(Session session, string serverOpaqueRef, Sess
230217
231218 #region Properties
232219
220+ /// <summary>
221+ /// The WebProxy to use for each HTTP request.
222+ /// </summary>
223+ public IWebProxy Proxy
224+ {
225+ get => JsonRpcClient . WebProxy ;
226+ set => JsonRpcClient . WebProxy = value ;
227+ }
228+
229+ public API_Version APIVersion { get ; private set ; } = API_Version . UNKNOWN ;
230+
231+ public object Tag { get ; set ; }
232+
233233 /// <summary>
234234 /// Retrieves the current users details from the UserDetails map. These values are only updated when a new session is created.
235235 /// </summary>
@@ -239,15 +239,24 @@ public override string SaveChanges(Session session, string serverOpaqueRef, Sess
239239
240240 public string Url => JsonRpcClient . Url ;
241241
242+ /// <summary>
243+ /// The UserAgent to use for each HTTP request. If set to null or empty the DefaultUserAgent will be used.
244+ /// </summary>
245+ public string UserAgent
246+ {
247+ get => JsonRpcClient . UserAgent ;
248+ set => JsonRpcClient . UserAgent = value ;
249+ }
250+
242251 public string ConnectionGroupName
243252 {
244- get => JsonRpcClient ? . ConnectionGroupName ;
253+ get => JsonRpcClient . ConnectionGroupName ;
245254 set => JsonRpcClient . ConnectionGroupName = value ;
246255 }
247256
248257 public int Timeout
249258 {
250- get => JsonRpcClient ? . Timeout ?? STANDARD_TIMEOUT ;
259+ get => JsonRpcClient . Timeout ;
251260 set => JsonRpcClient . Timeout = value ;
252261 }
253262
0 commit comments