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


C# ODataMessageReader.ReadServiceDocument方法代码示例

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


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

示例1: ServiceDocumentNoWhitespaceTest


//.........这里部分代码省略.........
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<atom:title>Products</atom:title>" +
                            "<accept>image/png</accept>" +
                            "<categories href='http://somecategories.com'/>" +
                        "</collection>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<accept>image/png</accept>" +
                            "<categories href='http://somecategories.com'/>" +
                            "<atom:title>Products</atom:title>" +
                        "</collection>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<accept>image/png</accept>" +
                            "<categories href='http://somecategories.com'/>" +
                            "<atom:title>Products</atom:title>" +
                        "</collection>" +
                        "<collection href='http://odata.org/Orders'>" +
                            "<accept>image/png</accept>" +
                            "<categories href='http://somecategories.com'/>" +
                            "<atom:title>Orders</atom:title>" +
                        "</collection>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<cf:cf xmlns:cf='uri'/>" +
                        "</collection>" +
                        "<collection href='http://odata.org/Orders'>" +
                            "<cf:cf xmlns:cf='uri'/>" +
                        "</collection>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<cf:cf xmlns:cf='uri'/>" +
                        "</collection>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<collection href='http://odata.org/Products'>" +
                            "<cf:cf xmlns:cf='uri'/>" +
                        "</collection>" +
                        "<cf:cf xmlns:cf='uri'/>" +
                        "<collection href='http://odata.org/Orders'>" +
                            "<cf:cf xmlns:cf='uri'/>" +
                        "</collection>" +
                        "<cf:cf xmlns:cf='uri'/>" +
                    "</workspace>" +
                "</service>",
                "<service xmlns:app='http://www.w3.org/2007/app' " +
                     "xmlns='http://www.w3.org/2007/app' xmlns:atom='http://www.w3.org/2005/Atom'>" +
                     "<workspace>" +
                        "<cf:cf xmlns:cf='uri'/>" +
                    "</workspace>" +
                "</service>",
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testCases,
                testCase =>
                {
                    // Just validate that the input strings above don't include any whitespaces.
                    using (XmlReader xmlReader = XmlReader.Create(new StringReader(testCase)))
                    {
                        while (xmlReader.Read())
                        {
                            this.Assert.AreNotEqual(XmlNodeType.Whitespace, xmlReader.NodeType, "No whitespaces please");
                            this.Assert.AreNotEqual(XmlNodeType.SignificantWhitespace, xmlReader.NodeType, "No whitespaces please");
                        }
                    }

                    // Run the payload through the reader and make sure it doesn't fail.
                    TestResponseMessage message = new TestResponseMessage(new MemoryStream(Encoding.UTF8.GetBytes(testCase)));
                    message.SetContentType(ODataFormat.Atom, ODataPayloadKind.ServiceDocument);
                    ODataMessageReaderSettings settings = new ODataMessageReaderSettings { EnableAtom = true };

                    using (ODataMessageReader messageReader = new ODataMessageReader(message, settings))
                    {
                        messageReader.ReadServiceDocument();
                    }
                });
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:101,代码来源:ServiceDocumentReaderAtomTests.cs

示例2: ValidServiceDocument

        public void ValidServiceDocument()
        {
            var metadataMessage = new HttpWebRequestMessage(new Uri(ServiceUri + "$metadata"));
            metadataMessage.SetHeader("Accept", MimeTypes.ApplicationXml);

            var metadataMessageReader = new ODataMessageReader(metadataMessage.GetResponse());
            var model = metadataMessageReader.ReadMetadataDocument();

            var message = new HttpWebRequestMessage(ServiceUri);
            message.SetHeader("Accept", MimeTypes.ApplicationJson);
            ODataMessageReaderSettings readerSettings = new ODataMessageReaderSettings() { BaseUri = ServiceUri };

            using (var messageReader = new ODataMessageReader(message.GetResponse(), readerSettings, model))
            {
                var workspace = messageReader.ReadServiceDocument();
                Assert.AreEqual(21, workspace.EntitySets.Count(e => e.Name.StartsWith("EF")));
                Assert.AreEqual(24, workspace.EntitySets.Count(e => !e.Name.StartsWith("EF")));
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:19,代码来源:HybridServiceTests.cs

示例3: ServiceDocumentTest

        public async Task ServiceDocumentTest(string format)
        {
            // Act
            var requestUri = string.Format("{0}/odata?$format={1}", BaseAddress, format);
            var response = await Client.GetAsync(requestUri);
            var stream = await response.Content.ReadAsStreamAsync();

            //Assert
            var oDataMessageReaderSettings = new ODataMessageReaderSettings();
            IODataResponseMessage message = new ODataMessageWrapper(stream, response.Content.Headers);
            var reader = new ODataMessageReader(message, oDataMessageReaderSettings, UnboundFunctionEdmModel.GetEdmModel());
            var oDataWorkSpace = reader.ReadServiceDocument();

            var function1 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetAllConventionCustomers");
            Assert.Equal(1, function1.Count());
            var function2 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetConventionOrderByCustomerIdAndOrderName");
            // ODL spec says:
            // The edm:FunctionImport for a parameterless function MAY include the IncludeInServiceDocument attribute
            // whose Boolean value indicates whether the function import is advertised in the service document.
            // So the below 2 FunctionImports are not displayed in ServiceDocument.
            Assert.Equal(0, function2.Count());
            var function3 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetConventionCustomerById");
            Assert.Equal(0, function3.Count());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:24,代码来源:UnboundOperationTest.cs


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