forked from jwaliszko/ExpressiveAnnotations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestStorage.cs
More file actions
38 lines (34 loc) · 1.2 KB
/
Copy pathRequestStorage.cs
File metadata and controls
38 lines (34 loc) · 1.2 KB
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
/* https://github.com/JaroslawWaliszko/ExpressiveAnnotations
* Copyright (c) 2014 Jaroslaw Waliszko
* Licensed MIT: http://opensource.org/licenses/MIT */
using System;
using System.Collections;
using System.Web;
namespace ExpressiveAnnotations.MvcUnobtrusiveValidatorProvider
{
/// <summary>
/// Stores arbitrary data for the current HTTP request.
/// </summary>
internal class RequestStorage
{
private static IDictionary Items
{
get
{
if (HttpContext.Current == null)
throw new ApplicationException("HttpContext not available.");
return HttpContext.Current.Items; // location that could be used throughtout the entire HTTP request lifetime
} // (contrary to a session, this one exists only within the period of a single request).
}
public static T Get<T>(string key)
{
return Items[key] == null
? default(T)
: (T) Items[key];
}
public static void Set<T>(string key, T value)
{
Items[key] = value;
}
}
}