本文整理汇总了C#中System.Net.Http.HttpRequestMessage.SetOwinEnvironment方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.SetOwinEnvironment方法的具体用法?C# HttpRequestMessage.SetOwinEnvironment怎么用?C# HttpRequestMessage.SetOwinEnvironment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpRequestMessage
的用法示例。
在下文中一共展示了HttpRequestMessage.SetOwinEnvironment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOwinEnvironment_ReturnsSetEnvironment
public void GetOwinEnvironment_ReturnsSetEnvironment()
{
var request = new HttpRequestMessage();
var environment = new Dictionary<string, object>();
request.SetOwinEnvironment(environment);
Assert.Equal(environment, request.GetOwinEnvironment());
}
示例2: GetOwinResponse_ReturnsResponseForOwinEnvironment
public void GetOwinResponse_ReturnsResponseForOwinEnvironment()
{
// Arrange
IDictionary<string, object> expectedEnvironment = new Dictionary<string, object>();
using (HttpRequestMessage request = new HttpRequestMessage())
{
request.SetOwinEnvironment(expectedEnvironment);
// Act
OwinResponse response = request.GetOwinResponse();
// Assert
Assert.Same(expectedEnvironment, response.Environment);
}
}
示例3: CreateRequestWithOwinEnvironment
private static HttpRequestMessage CreateRequestWithOwinEnvironment(IDictionary<string, object> environment)
{
HttpRequestMessage request = new HttpRequestMessage();
request.SetOwinEnvironment(environment);
return request;
}
开发者ID:samgithub-duplicate,项目名称:aspnetwebstack,代码行数:6,代码来源:PassiveAuthenticationMessageHandlerTest.cs
示例4: MapRequestProperties
private static void MapRequestProperties(HttpRequestMessage request, IDictionary<string, object> environment, string requestPathBase)
{
// Set the environment on the request
request.SetOwinEnvironment(environment);
// Set the virtual path root for link resolution and link generation to work
// OWIN spec requires request path base to be either the empty string or start with "/"
request.SetVirtualPathRoot(requestPathBase.Length == 0 ? "/" : requestPathBase);
// Set a delegate to get the client certificate
request.Properties[HttpPropertyKeys.RetrieveClientCertificateDelegateKey] = new Func<HttpRequestMessage, X509Certificate2>(
req =>
{
X509Certificate2 clientCertificate;
return environment.TryGetValue<X509Certificate2>(OwinConstants.ClientCertifiateKey, out clientCertificate) ? clientCertificate : null;
});
// Set a lazily-evaluated way of determining whether the request is local or not
Lazy<bool> isLocal = new Lazy<bool>(() =>
{
bool local;
if (environment.TryGetValue(OwinConstants.IsLocalKey, out local))
{
return local;
}
return false;
}, isThreadSafe: false);
request.Properties[HttpPropertyKeys.IsLocalKey] = isLocal;
}
示例5: GetOwinContext_ReturnsOwinContext_AfterSetContextEnvironment
public void GetOwinContext_ReturnsOwinContext_AfterSetContextEnvironment()
{
// Arrange
var request = new HttpRequestMessage();
var environment = new Dictionary<string, object>();
request.SetOwinEnvironment(environment);
// Act
IOwinContext context = request.GetOwinContext();
// Assert
Assert.IsType<OwinContext>(context);
Assert.Same(environment, context.Environment);
}
示例6: GetOwinEnvironment_ReturnsSetEnvironmentInstance
public void GetOwinEnvironment_ReturnsSetEnvironmentInstance()
{
// Arrange
var request = new HttpRequestMessage();
var environment = new Dictionary<string, object>();
request.SetOwinEnvironment(environment);
// Act & Assert
Assert.Same(environment, request.GetOwinEnvironment());
}