Пример #1
0
 public override void WriteStart(DataServiceODataWriterFeedArgs args)
 {
     base.WriteStart(args);
     foreach (var annotation in CustomInstanceAnnotationsGenerator.GetDuplicateAnnotations())
     {
         args.Feed.InstanceAnnotations.Add(annotation);
     }
 }
Пример #2
0
            public override void WriteEnd(DataServiceODataWriterFeedArgs args)
            {
                if (WriteFeedEnd.Value != null)
                {
                    if (WriteFeedEnd.Value(args))
                    {
                        return;
                    }
                }

                base.WriteEnd(args);
            }
        public override void WriteStart(DataServiceODataWriterFeedArgs args)
        {
            CustomInstanceAnnotationsDescriptor current;

            if (writtenItemsStack.Count == 0)
            {
                current = new CustomInstanceAnnotationsDescriptor
                {
                    TypeOfAnnotatedItem = typeof(ODataResourceSet),
                    Parent             = null,
                    AnnotationsOnStart = new Collection <ODataInstanceAnnotation>(CustomInstanceAnnotationsGenerator.GetAnnotations("AnnotationOnFeed.AddedBeforeWriteStart.").Concat(CustomInstanceAnnotationsGenerator.GetAnnotationsWithTermInMetadata()).ToList()),
                    AnnotationsOnEnd   = new Collection <ODataInstanceAnnotation>(CustomInstanceAnnotationsGenerator.GetAnnotations("AnnotationOnFeed.AddedAfterWriteStart.").ToList()),
                };
            }
            else
            {
                current = new CustomInstanceAnnotationsDescriptor
                {
                    TypeOfAnnotatedItem = typeof(ODataResourceSet),
                    Parent             = writtenItemsStack.Peek(),
                    AnnotationsOnEnd   = new Collection <ODataInstanceAnnotation>(),
                    AnnotationsOnStart = new Collection <ODataInstanceAnnotation>()
                };
            }

            AnnotatedItemsBaseline.Add(current);
            writtenItemsStack.Push(current);

            foreach (var annotation in current.AnnotationsOnStart)
            {
                args.Feed.InstanceAnnotations.Add(annotation);
            }

            base.WriteStart(args);

            foreach (var annotation in current.AnnotationsOnEnd)
            {
                args.Feed.InstanceAnnotations.Add(annotation);
            }
        }