public override void WriteStart(DataServiceODataWriterEntryArgs args)
        {
            CustomInstanceAnnotationsDescriptor current = new CustomInstanceAnnotationsDescriptor
            {
                TypeOfAnnotatedItem = typeof(ODataResource),
                Parent             = writtenItemsStack.Count == 0 ? null : writtenItemsStack.Peek(),
                AnnotationsOnStart = new Collection <ODataInstanceAnnotation>(CustomInstanceAnnotationsGenerator.GetAnnotations("AnnotationOnEntry.AddedBeforeWriteStart.").ToList()),
                AnnotationsOnEnd   = new Collection <ODataInstanceAnnotation>(CustomInstanceAnnotationsGenerator.GetAnnotations("AnnotationOnEntry.AddedAfterWriteStart.").Concat(CustomInstanceAnnotationsGenerator.GetAnnotationsWithTermInMetadata()).ToList()),
            };

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

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

            base.WriteStart(args);

            foreach (var annotation in current.AnnotationsOnEnd)
            {
                args.Entry.InstanceAnnotations.Add(annotation);
            }
        }
Ejemplo n.º 2
0
 public override void WriteStart(DataServiceODataWriterEntryArgs args)
 {
     base.WriteStart(args);
     foreach (var annotation in CustomInstanceAnnotationsGenerator.GetDuplicateAnnotations())
     {
         args.Entry.InstanceAnnotations.Add(annotation);
     }
 }