当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestMessage.SetOwinEnvironment方法代码示例

本文整理汇总了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());
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:8,代码来源:OwinHttpRequestMessageExtensionsTest.cs

示例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);
            }
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:16,代码来源:OwinHttpRequestMessageExtensionsTest.cs

示例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;
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:29,代码来源:HttpMessageHandlerAdapter.cs

示例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);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:14,代码来源:OwinHttpRequestMessageExtensionsTest.cs

示例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());
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:10,代码来源:OwinHttpRequestMessageExtensionsTest.cs


注:本文中的System.Net.Http.HttpRequestMessage.SetOwinEnvironment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。