Ejemplo n.º 1
0
        private static void WriteTopLevelEntityReferenceLinks()
        {
            Console.WriteLine("WriteTopLevelEntityReferenceLinks");

            var msg = ODataSamplesUtil.CreateMessage();

            msg.PreferenceAppliedHeader().AnnotationFilter = "*";

            var link1 = new ODataEntityReferenceLink()
            {
                Url = new Uri("http://demo/odata.svc/People(3)")
            };
            var link2 = new ODataEntityReferenceLink()
            {
                Url = new Uri("http://demo/odata.svc/People(4)")
            };

            var links = new ODataEntityReferenceLinks()
            {
                Links = new[] { link1, link2 }
            };

            using (var omw = new ODataMessageWriter((IODataResponseMessage)msg, BaseSettings, ExtModel.Model))
            {
                omw.WriteEntityReferenceLinks(links);
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }
Ejemplo n.º 2
0
        private static void WriteTopLevelEntry()
        {
            Console.WriteLine("WriteTopLevelEntry");

            var msg = ODataSamplesUtil.CreateMessage();

            msg.PreferenceAppliedHeader().AnnotationFilter = "*";

            using (var omw = new ODataMessageWriter((IODataResponseMessage)msg, BaseSettings, ExtModel.Model))
            {
                var writer = omw.CreateODataEntryWriter(ExtModel.People);
                writer.WriteStart(PersonEntry);

                writer.WriteStart(PersonPetsNavigationLink);
                writer.WriteStart(new ODataFeed());
                writer.WriteStart(PetEntry);
                writer.WriteEnd();
                writer.WriteEnd();
                writer.WriteEnd();

                writer.WriteStart(PersonFavouritePetNavigationLink);
                writer.WriteStart(PetEntry);
                writer.WriteEnd();
                writer.WriteEnd();

                writer.WriteEnd();
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }
Ejemplo n.º 3
0
        private static void WriteTopLevelFeed(bool enableFullValidation = true)
        {
            var msg = ODataSamplesUtil.CreateMessage();

            var settings = new ODataMessageWriterSettings(BaseSettings)
            {
                ODataUri = new ODataUri()
                {
                    ServiceRoot = new Uri("http://demo/odata.svc/PetSet")
                },
                EnableFullValidation = enableFullValidation
            };

            using (var omw = new ODataMessageWriter((IODataResponseMessage)msg, settings, ExtModel.Model))
            {
                var writer = omw.CreateODataFeedWriter(ExtModel.PetSet);
                writer.WriteStart(Feed);
                writer.WriteStart(PetEntry);
                writer.WriteEnd();
                writer.WriteStart(FishEntry);
                writer.WriteEnd();
                writer.WriteEnd();
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }
Ejemplo n.º 4
0
        private static void WriteTopLevelEntry()
        {
            Console.WriteLine("WriteTopLevelEntry");

            var msg = ODataSamplesUtil.CreateMessage();

            msg.PreferenceAppliedHeader().AnnotationFilter = "*";

            var settings = new ODataMessageWriterSettings(BaseSettings)
            {
                ODataUri = new ODataUri()
                {
                    ServiceRoot = ServiceRoot
                },
            };

            using (var omw = new ODataMessageWriter((IODataResponseMessage)msg, settings, ExtModel.Model))
            {
                var writer = omw.CreateODataEntryWriter(ExtModel.People);
                writer.WriteStart(PersonEntry);
                writer.WriteEnd();
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }
Ejemplo n.º 5
0
        private static void WriteInnerEntityReferenceLink()
        {
            Console.WriteLine("WriteInnerEntityReferenceLink in Request Payload (odata.bind)");

            var msg = ODataSamplesUtil.CreateMessage();

            msg.PreferenceAppliedHeader().AnnotationFilter = "*";

            var link1 = new ODataEntityReferenceLink
            {
                Url = new Uri("http://demo/odata.svc/PetSet(Id=1,Color=TestNS.Color'Blue')")
            };
            var link2 = new ODataEntityReferenceLink
            {
                Url = new Uri("http://demo/odata.svc/PetSet(Id=2,Color=TestNS.Color'Blue')")
            };

            using (var omw = new ODataMessageWriter((IODataRequestMessage)msg, BaseSettings, ExtModel.Model))
            {
                var writer = omw.CreateODataEntryWriter(ExtModel.People);
                writer.WriteStart(PersonEntry);

                writer.WriteStart(PersonPetsNavigationLink);
                writer.WriteEntityReferenceLink(link1);
                writer.WriteEntityReferenceLink(link2);
                writer.WriteEnd();

                writer.WriteStart(PersonFavouritePetNavigationLink);
                writer.WriteEntityReferenceLink(link1);
                writer.WriteEnd();

                writer.WriteEnd();
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }
Ejemplo n.º 6
0
        private static void WriteTopLevelFeed(bool enableFullValidation = true)
        {
            Console.WriteLine("WriteTopLevelFeed, enableFullValidation:{0}", enableFullValidation);

            var msg = ODataSamplesUtil.CreateMessage();

            var settings = new ODataMessageWriterSettings(BaseSettings)
            {
                EnableFullValidation = enableFullValidation
            };

            using (var omw = new ODataMessageWriter((IODataResponseMessage)msg, settings, ExtModel.Model))
            {
                var writer = omw.CreateODataFeedWriter(ExtModel.PetSet);
                writer.WriteStart(Feed);
                writer.WriteStart(PetEntry);
                writer.WriteEnd();
                writer.WriteStart(FishEntry);
                writer.WriteEnd();
                writer.WriteEnd();
            }

            Console.WriteLine(ODataSamplesUtil.MessageToString(msg));
        }