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
33 lines (31 loc) · 1.03 KB
/
RequestContextExtensions.cs
File metadata and controls
33 lines (31 loc) · 1.03 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
#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;
var httpReq = requestContext.Get<IHttpRequest>();
if (httpReq != null)
httpReq.Items[key] = value;
}
/// <summary>
/// Get an entry from the IHttpRequest.Items Dictionary
/// </summary>
public static object GetItem(this IRequestContext requestContext, string key)
{
if (requestContext == null) return null;
object value = null;
var httpReq = requestContext.Get<IHttpRequest>();
if (httpReq != null)
httpReq.Items.TryGetValue(key, out value);
return value;
}
}
}
#endif