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


C# MediaRange.ToString方法代码示例

本文整理汇总了C#中Nancy.Responses.Negotiation.MediaRange.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MediaRange.ToString方法的具体用法?C# MediaRange.ToString怎么用?C# MediaRange.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Responses.Negotiation.MediaRange的用法示例。


在下文中一共展示了MediaRange.ToString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_strip_whitespace_when_calling_tostring

        public void Should_strip_whitespace_when_calling_tostring()
        {
            // Given
            var range = new MediaRange("application/vnd.nancy ; a=1; b=2");

            // Then
            range.ToString().ShouldEqual("application/vnd.nancy;a=1;b=2");
        }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:8,代码来源:MediaRangeFixture.cs

示例2: Should_include_parameters_when_calling_tostring

        public void Should_include_parameters_when_calling_tostring()
        {
            // Given
            var range = new MediaRange("application/vnd.nancy;a=1;b=2");

            // Then
            range.ToString().ShouldEqual("application/vnd.nancy;a=1;b=2");
        }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:8,代码来源:MediaRangeFixture.cs

示例3: Should_handle_no_parameters_when_calling_tostring

        public void Should_handle_no_parameters_when_calling_tostring()
        {
            // Given
            var range = new MediaRange("application/vnd.nancy");

            // Then
            range.ToString().ShouldEqual("application/vnd.nancy");
        }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:8,代码来源:MediaRangeFixture.cs

示例4: CanDeserialize

        /// <summary>
        /// Whether the deserializer can deserialize the content type
        /// </summary>
        /// <param name="mediaRange">Content type to deserialize</param>
        /// <param name="context">Current <see cref="BindingContext"/>.</param>
        /// <returns>True if supported, false otherwise</returns>
        public bool CanDeserialize(MediaRange mediaRange, BindingContext context)
        {
            if (string.IsNullOrEmpty(mediaRange))
            {
                return false;
            }

            var contentMimeType = mediaRange.ToString().Split(';')[0];

            return contentMimeType.Equals("application/xml", StringComparison.OrdinalIgnoreCase) ||
                   contentMimeType.Equals("text/xml", StringComparison.OrdinalIgnoreCase) ||
                  (contentMimeType.StartsWith("application/vnd", StringComparison.OrdinalIgnoreCase) &&
                   contentMimeType.EndsWith("+xml", StringComparison.OrdinalIgnoreCase));
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:20,代码来源:XmlBodyDeserializer.cs

示例5: TestSparqlPostSucceeds

        private static void TestSparqlPostSucceeds(string storeName, string query, IEnumerable<string> defaultGraphUris, IEnumerable<string> namedGraphUris, MediaRange accept, SparqlResultsFormat expectedQueryFormat, Action<Mock<IBrightstarService>> brightstarSetup)
        {
            // Setup
            var brightstar = new Mock<IBrightstarService>();
            brightstar.Setup(s => s.ExecuteQuery(storeName, query, defaultGraphUris, null, expectedQueryFormat))
                      .Returns(new MemoryStream(Encoding.UTF8.GetBytes("Mock Results")))
                      .Verifiable();
            if (brightstarSetup != null) brightstarSetup(brightstar);
            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));

            // Execute
            var response = app.Post("/" + storeName + "/sparql", with =>
            {
                with.Body(query);
                with.Header("Content-Type", "application/sparql-query");
                if (defaultGraphUris != null)
                {
                    foreach (var defaultGraphUri in defaultGraphUris)
                    {
                        with.Query("default-graph-uri", defaultGraphUri);
                    }
                }
                if (namedGraphUris != null)
                {
                    foreach (var namedGraphUri in namedGraphUris)
                    {
                        with.Query("named-graph-uri", namedGraphUri);
                    }
                }
                with.Accept(accept);
            });

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(response.ContentType, Is.EqualTo(accept.ToString()));
            Assert.That(response.Body.AsString(), Is.EqualTo("Mock Results"));
            brightstar.Verify();
        }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:37,代码来源:SparqlUrlSpec.cs

示例6: TestGetSucceeds

        private static BrowserResponse TestGetSucceeds(
            string storeName, string query, IEnumerable<string> defaultGraphUris, 
            IEnumerable<string> namedGraphUris, 
            MediaRange accept,
            Action<Mock<IBrightstarService>> brightstarSetup)
        {
            // Setup
            var brightstar = new Mock<IBrightstarService>();
            brightstarSetup(brightstar);
            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
            if (accept == null) accept = MediaRange.FromString("application/sparql-results+xml");
            // Execute
            var response = app.Get("/" + storeName + "/sparql", with =>
                {
                    with.Query("query", query);
                    if (defaultGraphUris != null)
                    {
                        foreach (var defaultGraph in defaultGraphUris)
                        {
                            with.Query("default-graph-uri", defaultGraph);
                        }
                    }
                    if (namedGraphUris != null)
                    {
                        foreach (var namedGraph in namedGraphUris)
                        {
                            with.Query("named-graph-uri", namedGraph);
                        }
                    }
                    with.Accept(accept);
                });

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(response.ContentType, Is.EqualTo(accept.ToString()));
            brightstar.Verify();
            return response;
        }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:37,代码来源:SparqlUrlSpec.cs


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