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


C# Core.ODataFeed类代码示例

本文整理汇总了C#中Microsoft.OData.Core.ODataFeed的典型用法代码示例。如果您正苦于以下问题:C# ODataFeed类的具体用法?C# ODataFeed怎么用?C# ODataFeed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ODataFeed类属于Microsoft.OData.Core命名空间,在下文中一共展示了ODataFeed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Visit

        /// <summary>
        /// Visits an entity set instance: creates a new ODataFeed instance, calls ODataWriter.WriteStart()
        /// before visiting the entries and then calls ODataWriter.WriteEnd()
        /// </summary>
        /// <param name="payloadElement">The entity set instance to write.</param>
        public override void Visit(EntitySetInstance payloadElement)
        {
            // create an ODataFeed and write it
            ODataFeed feed = new ODataFeed()
            {
                // NOTE: the required Id is set when processing the annotations in AddFeedMetadata()
                Count = payloadElement.InlineCount,
                SerializationInfo = new ODataFeedAndEntrySerializationInfo()
                {
                    NavigationSourceEntityTypeName = "Null",
                    NavigationSourceName = "MySet",
                    ExpectedTypeName = "Null"
                }
            };

            if (payloadElement.NextLink != null)
            {
                feed.NextPageLink = new Uri(payloadElement.NextLink);
            }

            AddFeedMetadata(payloadElement, feed);

            this.writer.WriteStart(feed);
            base.Visit(payloadElement);
            this.writer.WriteEnd();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:31,代码来源:PayloadElementODataWriter.cs

示例2: CreateLink

 /// <summary>
 /// Creates the materializer link with a feed.
 /// </summary>
 /// <param name="link">The link.</param>
 /// <param name="feed">The feed.</param>
 /// <returns>The materializer link.</returns>
 public static MaterializerNavigationLink CreateLink(ODataNavigationLink link, ODataFeed feed)
 {
     Debug.Assert(link.GetAnnotation<MaterializerNavigationLink>() == null, "there should be no MaterializerNavigationLink annotation on the feed link yet");
     MaterializerNavigationLink materializedNavigationLink = new MaterializerNavigationLink(link, feed);
     link.SetAnnotation<MaterializerNavigationLink>(materializedNavigationLink);
     return materializedNavigationLink;
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:13,代码来源:MaterializerNavigationLink.cs

示例3: ShouldBeAbleToSetTheFeedSerializationInfo

 public void ShouldBeAbleToSetTheFeedSerializationInfo()
 {
     ODataFeed feed = new ODataFeed();
     ODataFeedAndEntrySerializationInfo serializationInfo = new ODataFeedAndEntrySerializationInfo { NavigationSourceName = "Set", NavigationSourceEntityTypeName = "ns.base", ExpectedTypeName = "ns.expected" };
     feed.SetSerializationInfo(serializationInfo);
     feed.SerializationInfo.Should().BeSameAs(serializationInfo);
 }
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:ODataObjectModelExtensionTests.cs

示例4: MaterializerFeed

        /// <summary>
        /// Prevents a default instance of the <see cref="MaterializerFeed"/> struct from being created.
        /// </summary>
        /// <param name="feed">The feed.</param>
        /// <param name="entries">The entries.</param>
        private MaterializerFeed(ODataFeed feed, IEnumerable<ODataEntry> entries)
        {
            Debug.Assert(feed != null, "feed != null");
            Debug.Assert(entries != null, "entries != null");

            this.feed = feed;
            this.entries = entries;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:13,代码来源:MaterializerFeed.cs

示例5: DataServiceODataWriterFeedArgs

 /// <summary>
 /// Creates a new instance of DataServiceODataWriterFeedArgs
 /// </summary>
 /// <param name="feed">ODataFeed instance.</param>
 /// <param name="results">IEnumerable instance that is getting serialized.</param>
 /// <param name="operationContext">DataServiceOperationContext instance.</param>
 public DataServiceODataWriterFeedArgs(ODataFeed feed, IEnumerable results, DataServiceOperationContext operationContext)
 {
     WebUtil.CheckArgumentNull(feed, "feed");
     Debug.Assert(results != null, "results != null");
     Debug.Assert(operationContext != null, "operationContext != null");
     this.Feed = feed;
     this.Results = results;
     this.OperationContext = operationContext;
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:DataServiceODataWriterFeedArgs.cs

示例6: Visit

        /// <summary>
        /// Visits an entity set instance: creates a new ODataFeed instance, calls ODataWriter.WriteStart()
        /// before visiting the entries and then calls ODataWriter.WriteEnd()
        /// </summary>
        /// <param name="payloadElement">The entity set instance to write.</param>
        public override void Visit(EntitySetInstance payloadElement)
        {
            // create an ODataFeed and write it
            ODataFeed feed = new ODataFeed()
            {
                // NOTE: the required Id is set when processing the annotations in AddFeedMetadata()
                Count = payloadElement.InlineCount,
                SerializationInfo = new ODataFeedAndEntrySerializationInfo() {
                    NavigationSourceEntityTypeName = "Null",
                    NavigationSourceName = "MySet",
                    ExpectedTypeName = "Null"
                }
            };

            var idAnnotation = payloadElement.Annotations.Where(a => 
                {
                    var annotation = a as XmlTreeAnnotation;
                    if (annotation != null)
                        return annotation.LocalName.Equals("id");
                    return false;
                }).SingleOrDefault();
            
            if (idAnnotation != null)
            {
                feed.Id = new Uri((idAnnotation as XmlTreeAnnotation).PropertyValue, UriKind.Absolute);
            }

            if (payloadElement.NextLink != null)
            {
                feed.NextPageLink = new Uri(payloadElement.NextLink);
            }

            AddFeedMetadata(payloadElement, feed);

            if (this.items.Count > 0 && this.items.Peek() is ODataNavigationLink)
            {
                var currentLink = this.items.Peek() as ODataNavigationLink;
                ExceptionUtilities.CheckObjectNotNull(currentLink, "Feed can only exist at top level or inside a navigation link");
                currentLink.SetAnnotation(new ODataNavigationLinkExpandedItemObjectModelAnnotation() { ExpandedItem = feed });
            }

            try
            {
                items.Push(feed);
                base.Visit(payloadElement);
            }
            finally
            {
                feed = (ODataFeed)items.Pop();
            }

            // If we are at the top level push this to items to make it the result.
            if (this.items.Count == 0)
            {
                this.items.Push(feed);
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:62,代码来源:ODataPayloadElementToObjectModelConverter.cs

示例7: PropertySettersNullTest

        public void PropertySettersNullTest()
        {
            ODataFeed feed = new ODataFeed();
            feed.Count = null;
            feed.NextPageLink = null;

            this.Assert.IsNull(feed.Count, "Expected null value for property 'Count'.");
            this.Assert.IsNull(feed.NextPageLink, "Expected null value for property 'NextPageLink'.");
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:9,代码来源:ODataFeedTests.cs

示例8: WriteFeed

        /// <summary>
        /// Writes an OData feed.
        /// </summary>
        /// <param name="writer">The ODataWriter that will write the feed.</param>
        /// <param name="entries">The items from the data store to write to the feed.</param>
        /// <param name="entitySet">The entity set in the model that the feed belongs to.</param>
        /// <param name="model">The data store model.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <param name="expandedNavigationProperties">A list of navigation property names to expand.</param>
        public static void WriteFeed(ODataWriter writer, IEnumerable entries, IEdmEntitySet entitySet, IEdmModel model, ODataVersion targetVersion, IEnumerable<string> expandedNavigationProperties)
        {
            var feed = new ODataFeed {Id = new Uri(ServiceConstants.ServiceBaseUri, entitySet.Name)};
            writer.WriteStart(feed);

            foreach (var element in entries)
            {
                WriteEntry(writer, element, entitySet, model, targetVersion, expandedNavigationProperties);
            }

            writer.WriteEnd();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:21,代码来源:ResponseWriter.cs

示例9: VisitFeed

            /// <summary>
            /// Visits a feed item.
            /// </summary>
            /// <param name="feed">The feed to visit.</param>
            protected override ODataPayloadElement VisitFeed(ODataFeed feed)
            {
                ODataPayloadElement payloadElement = base.VisitFeed(feed);
                ODataFeedPayloadOrderObjectModelAnnotation payloadOrderFeedAnnotation = feed.GetAnnotation<ODataFeedPayloadOrderObjectModelAnnotation>();
                if (payloadOrderFeedAnnotation != null)
                {
                    PayloadOrderODataPayloadElementAnnotation payloadOrderElementAnnotation = new PayloadOrderODataPayloadElementAnnotation();
                    payloadOrderElementAnnotation.PayloadItems.AddRange(payloadOrderFeedAnnotation.PayloadItems);
                    payloadElement.Add(payloadOrderElementAnnotation);
                }

                return payloadElement;
            }
开发者ID:larsenjo,项目名称:odata.net,代码行数:17,代码来源:ObjectModelToPayloadElementPayloadWithPayloadOrderConverter.cs

示例10: CreateFeed

        /// <summary>
        /// Creates the materializer feed.
        /// </summary>
        /// <param name="feed">The feed.</param>
        /// <param name="entries">The entries.</param>
        /// <returns>The materializer feed.</returns>
        public static MaterializerFeed CreateFeed(ODataFeed feed, IEnumerable<ODataEntry> entries)
        {
            Debug.Assert(feed.GetAnnotation<IEnumerable<ODataEntry>>() == null, "Feed state has already been created.");
            if (entries == null)
            {
                entries = Enumerable.Empty<ODataEntry>();
            }
            else
            {
                feed.SetAnnotation<IEnumerable<ODataEntry>>(entries);
            }

            return new MaterializerFeed(feed, entries);
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:20,代码来源:MaterializerFeed.cs

示例11: WriteStart

        /// <summary>
        /// Start writing a feed.
        /// </summary>
        /// <param name="feed">Feed/collection to write.</param>
        public override void WriteStart(ODataFeed feed)
        {
            if (this.testConfiguration.Synchronous)
            {
                this.writer.WriteStart(feed);
            }
            else
            {
#if WINDOWS_PHONE
                throw new TaupoNotSupportedException("This test is not supported in asynchronous mode in Silverlight or Windows Phone");
#else
                this.writer.WriteStartAsync(feed).Wait();
#endif
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:19,代码来源:ODataWriterTestWrapper.cs

示例12: PropertyGettersAndSettersTest

        public void PropertyGettersAndSettersTest()
        {
            int count = -2;
            Uri nextPageLink = new Uri("http://odatatest.org/page?id=2");

            ODataFeed feed = new ODataFeed()
            {
                Count = count,
                NextPageLink = nextPageLink
            };


            this.Assert.AreEqual(count, feed.Count, EqualityComparer<long?>.Default, "Expected equal Count values.");
            this.Assert.AreSame(nextPageLink, feed.NextPageLink, "Expected reference equal values for property 'NextPageLink'.");
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:ODataFeedTests.cs

示例13: WriteStartShouldIgnoreDeltaLinkWhenWritingResponseTopLevelFeed

        public void WriteStartShouldIgnoreDeltaLinkWhenWritingResponseTopLevelFeed()
        {
            string expectedPayload =
                 @"<?xml version=""1.0"" encoding=""utf-8""?>"
                + @"<feed xmlns=""http://www.w3.org/2005/Atom"" xmlns:d=""http://docs.oasis-open.org/odata/ns/data"" xmlns:m=""http://docs.oasis-open.org/odata/ns/metadata"" xmlns:georss=""http://www.georss.org/georss"" xmlns:gml=""http://www.opengis.net/gml"" m:context=""http://www.example.com/$metadata#TestEntitySet"">"
                    + "<id>http://host/TestEntitySet</id>"
                    + "<title />";

            Action<ODataWriter> deltaLinkAtWriteStart = (odataWriter) =>
            {
                var feedToWrite = new ODataFeed { Id = new Uri("http://host/TestEntitySet", UriKind.Absolute), DeltaLink = new Uri("http://host/deltaLink", UriKind.Absolute) };
                odataWriter.WriteStart(feedToWrite);
            };

            WriteAnnotationsAndValidatePayload(deltaLinkAtWriteStart, ODataFormat.Atom, expectedPayload, request: false, createFeedWriter: true);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:16,代码来源:DeltaLinkAtomWriterIntegrationTests.cs

示例14: ValidateShortIntegrationFeedReading

        public void ValidateShortIntegrationFeedReading()
        {
            var initialFeed = new ODataFeed() {Id = new Uri("http://services.odata.org/OData/OData.svc/Products")};
            
            var productItem = new ODataEntry() {Id = new Uri("http://services.odata.org/OData/OData.svc/Products(0)")};
            productItem.Properties = new ODataProperty[] {new ODataProperty() {Name = "Id", Value = 0}};

            var categoryNavigationLink = new ODataNavigationLink() {Name = "Category"};

            var categoryItem = new ODataEntry() { Id = new Uri("http://services.odata.org/OData/OData.svc/Categories(0)") };
            categoryItem.Properties = new ODataProperty[] { new ODataProperty() { Name = "Id", Value = 0 } };

            var productsNavigationLink = new ODataNavigationLink() { Name = "Products" };

            var supplierNavigationLink = new ODataNavigationLink() { Name = "Supplier" };

            var testODataReader = new TestODataReader()
            {
               new TestODataReaderItem(ODataReaderState.FeedStart, initialFeed),
               new TestODataReaderItem(ODataReaderState.EntryStart, productItem),
               new TestODataReaderItem(ODataReaderState.NavigationLinkStart, categoryNavigationLink),
               new TestODataReaderItem(ODataReaderState.EntryStart, categoryItem),
               new TestODataReaderItem(ODataReaderState.NavigationLinkStart, productsNavigationLink),
               new TestODataReaderItem(ODataReaderState.NavigationLinkEnd, productsNavigationLink),
               new TestODataReaderItem(ODataReaderState.EntryEnd, categoryItem),
               new TestODataReaderItem(ODataReaderState.NavigationLinkEnd, categoryNavigationLink),
               new TestODataReaderItem(ODataReaderState.NavigationLinkStart, supplierNavigationLink),
               new TestODataReaderItem(ODataReaderState.NavigationLinkEnd, supplierNavigationLink),
               new TestODataReaderItem(ODataReaderState.EntryEnd, productItem),
               new TestODataReaderItem(ODataReaderState.FeedEnd, initialFeed),
            };

            ClientEdmModel clientEdmModel = new ClientEdmModel(ODataProtocolVersion.V4);

            var responsePipeline = new DataServiceClientResponsePipelineConfiguration(new DataServiceContext());
            var odataReaderWrapper = ODataReaderWrapper.CreateForTest(testODataReader, responsePipeline);
            FeedAndEntryMaterializerAdapter reader = new FeedAndEntryMaterializerAdapter(ODataFormat.Atom, odataReaderWrapper, clientEdmModel, MergeOption.OverwriteChanges);

            int readCounter = 0;

            while (reader.Read())
            {
                readCounter++;
            }

            readCounter.Should().Be(2);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:47,代码来源:FeedAndEntryMaterializerAdapterUnitTests.cs

示例15: WriteStartShouldIgnoreDeltaLinkWhenWritingRequestTopLevelFeed

        public void WriteStartShouldIgnoreDeltaLinkWhenWritingRequestTopLevelFeed()
        {
            string expectedPayload =
            "{" +
                "\"@odata.context\":\"http://www.example.com/$metadata#TestEntitySet\"," +
                "\"value\":[]" +
            "}";

            Action<ODataWriter> deltaLinkAtWriteStart = (odataWriter) =>
            {
                var feedToWrite = new ODataFeed { DeltaLink = new Uri("http://host/deltaLink", UriKind.Absolute) };
                odataWriter.WriteStart(feedToWrite);
                odataWriter.WriteEnd();
            };

            WriteAnnotationsAndValidatePayload(deltaLinkAtWriteStart, ODataFormat.Json, expectedPayload, request: true, createFeedWriter: true);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:17,代码来源:DeltaLinkJsonLightWriterIntegrationTests.cs


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