forked from stevenh/HttpServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession.cs
57 lines (50 loc) · 1.49 KB
/
Session.cs
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
using System;
using System.Runtime.Serialization;
namespace HttpServer.Tools
{
/// <summary>
/// Base class for sessions.
/// </summary>
/// <remarks>
/// Your class must be tagged with <see cref="ISerializable"/> attribute to be able to use sessions.
/// </remarks>
[Serializable]
[Obsolete("Use the Sessions namespace instead")]
public class Session
{
[ThreadStatic] private static Session _currentSession;
/// <summary>
/// Gets or sets when session was accessed last
/// </summary>
public DateTime AccessedAt { get; set; }
/// <summary>
/// Gets current session.
/// </summary>
public static Session CurrentSession
{
get { return _currentSession; }
protected set { _currentSession = value; }
}
/// <summary>
/// Gets or sets session id.
/// </summary>
public string SessionId { get; set; }
/// <summary>
/// Gets or sets when the session was last written to disk.
/// </summary>
internal DateTime WrittenAt { get; set; }
/// <summary>
/// The session have been changed and should be written to disk.
/// </summary>
public void TriggerChanged()
{
if (Changed != null)
Changed(this);
}
/// <summary>
/// Session have been changed.
/// </summary>
[field: NonSerialized]
internal SessionChangedHandler Changed;
}
}