private void WriteEntry(ODataWriter writer, ODataItem entry)
        {
            ODataResource resource = entry as ODataResource;

            if (resource != null)
            {
                writer.WriteStart(resource);
            }
            else
            {
                writer.WritePrimitive((ODataPrimitiveValue)entry);
            }

            var annotation = entry.GetAnnotation <ODataEntryNavigationLinksObjectModelAnnotation>();
            ODataNestedResourceInfo navLink = null;

            if (annotation != null)
            {
                for (int i = 0; i < annotation.Count; ++i)
                {
                    bool found = annotation.TryGetNavigationLinkAt(i, out navLink);
                    ExceptionUtilities.Assert(found, "Navigation links should be ordered sequentially for writing");
                    this.WriteNavigationLink(writer, navLink);
                }
            }

            writer.WriteEnd();
        }
Ejemplo n.º 2
0
        protected static void AddChildInstanceAnnotations(ODataItem item, IList <object> childEntries)
        {
            var annotation = item.GetAnnotation <ChildInstanceAnnotation>();

            if (annotation == null)
            {
                annotation = new ChildInstanceAnnotation {
                    ChildInstances = childEntries
                };
                item.SetAnnotation(annotation);
            }
        }
Ejemplo n.º 3
0
        private void AddChildInstanceAnnotation(ODataItem item, object childEntry)
        {
            var annotation = item.GetAnnotation <ChildInstanceAnnotation>();

            if (annotation == null)
            {
                annotation = new ChildInstanceAnnotation {
                    ChildInstances = new List <object>()
                };
                item.SetAnnotation(annotation);
            }

            annotation.ChildInstances.Add(childEntry);
        }
Ejemplo n.º 4
0
        private void AddBoundNavigationPropertyAnnotation(ODataItem item, ODataNestedResourceInfo navigationLink, object boundValue)
        {
            var annotation = item.GetAnnotation <BoundNavigationPropertyAnnotation>();

            if (annotation == null)
            {
                annotation = new BoundNavigationPropertyAnnotation {
                    BoundProperties = new List <Tuple <ODataNestedResourceInfo, object> >()
                };
                item.SetAnnotation(annotation);
            }

            annotation.BoundProperties.Add(new Tuple <ODataNestedResourceInfo, object>(navigationLink, boundValue));
        }
Ejemplo n.º 5
0
        private void WriteEntry(ODataWriter writer, Lazy <ODataReader> lazyReader, ODataItem entry)
        {
            this.WriteStart(writer, entry);
            var annotation = entry.GetAnnotation <ODataEntryNavigationLinksObjectModelAnnotation>();
            ODataNestedResourceInfo navLink = null;

            if (annotation != null)
            {
                for (int i = 0; i < annotation.Count; ++i)
                {
                    bool found = annotation.TryGetNavigationLinkAt(i, out navLink);
                    ExceptionUtilities.Assert(found, "Navigation links should be ordered sequentially for writing");
                    this.WriteNavigationLink(writer, lazyReader, navLink);
                }
            }

            this.WriteEnd(writer, ODataReaderState.ResourceEnd);
            this.Read(lazyReader);
        }
Ejemplo n.º 6
0
        private void AddChildInstanceAnnotation(ODataItem item, object childEntry)
        {
            var annotation = item.GetAnnotation<ChildInstanceAnnotation>();
            if (annotation == null)
            { 
                annotation = new ChildInstanceAnnotation { ChildInstances = new List<object>() };
                item.SetAnnotation(annotation);
            }

            annotation.ChildInstances.Add(childEntry);
        }
Ejemplo n.º 7
0
        private void AddBoundNavigationPropertyAnnotation(ODataItem item, ODataNavigationLink navigationLink, object boundValue)
        {
            var annotation = item.GetAnnotation<BoundNavigationPropertyAnnotation>();
            if (annotation == null)
            { 
                annotation = new BoundNavigationPropertyAnnotation { BoundProperties = new List<Tuple<ODataNavigationLink, object>>() };
                item.SetAnnotation(annotation);
            }

            annotation.BoundProperties.Add(new Tuple<ODataNavigationLink, object>(navigationLink, boundValue));
        }