You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/Microsoft.AspNet.SignalR.Owin/RequestExtensions.cs

30 lines
914 B

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.AspNet.SignalR.Owin;
namespace Microsoft.AspNet.SignalR
{
public static class RequestExtensions
{
public static T GetOwinVariable<T>(this IRequest request, string key)
{
if (request == null)
{
throw new ArgumentNullException("request");
}
var env = request.Items.Get<IDictionary<string, object>>(ServerRequest.OwinEnvironmentKey);
return env == null ? default(T) : env.Get<T>(key);
}
private static T Get<T>(this IDictionary<string, object> values, string key)
{
object value;
return values.TryGetValue(key, out value) ? (T)value : default(T);
}
}
}