當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。