forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestContextExtensions.cs
More file actions
48 lines (42 loc) · 1.44 KB
/
RequestContextExtensions.cs
File metadata and controls
48 lines (42 loc) · 1.44 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
39
40
41
42
43
44
45
46
47
48
#if !SILVERLIGHT && !XBOX
using ServiceStack.ServiceHost;
namespace ServiceStack.Common
{
public static class RequestContextExtensions
{
/// <summary>
/// Store an entry in the IHttpRequest.Items Dictionary
/// </summary>
public static void SetItem(this IRequestContext requestContext, string key, object value)
{
if (requestContext == null) return;
requestContext.Get<IHttpRequest>().SetItem(key, value);
}
/// <summary>
/// Store an entry in the IHttpRequest.Items Dictionary
/// </summary>
public static void SetItem(this IHttpRequest httpReq, string key, object value)
{
if (httpReq == null) return;
httpReq.Items[key] = value;
}
/// <summary>
/// Get an entry from the IHttpRequest.Items Dictionary
/// </summary>
public static object GetItem(this IRequestContext requestContext, string key)
{
return requestContext == null ? null : requestContext.Get<IHttpRequest>().GetItem(key);
}
/// <summary>
/// Get an entry from the IHttpRequest.Items Dictionary
/// </summary>
public static object GetItem(this IHttpRequest httpReq, string key)
{
if (httpReq == null) return null;
object value;
httpReq.Items.TryGetValue(key, out value);
return value;
}
}
}
#endif