/// <summary> /// Searches for vocabulary annotations specified by this model. /// </summary> /// <param name="element">The annotated element.</param> /// <returns>The vocabulary annotations for the element.</returns> public override IEnumerable <IEdmVocabularyAnnotation> FindDeclaredVocabularyAnnotations(IEdmVocabularyAnnotatable element) { // Include the inline annotations only if this model is the one that defined them. CsdlSemanticsElement semanticsElement = element as CsdlSemanticsElement; IEnumerable <IEdmVocabularyAnnotation> inlineAnnotations = semanticsElement != null && semanticsElement.Model == this ? semanticsElement.InlineVocabularyAnnotations : Enumerable.Empty <IEdmVocabularyAnnotation>(); List <CsdlSemanticsAnnotations> elementAnnotations; string fullName = EdmUtil.FullyQualifiedName(element); if (fullName != null && this.outOfLineAnnotations.TryGetValue(fullName, out elementAnnotations)) { List <IEdmVocabularyAnnotation> result = new List <IEdmVocabularyAnnotation>(); foreach (CsdlSemanticsAnnotations annotations in elementAnnotations) { foreach (CsdlAnnotation annotation in annotations.Annotations.Annotations) { result.Add(this.WrapVocabularyAnnotation(annotation, annotations.Context, null, annotations, annotations.Annotations.Qualifier)); } } return(inlineAnnotations.Concat(result)); } return(inlineAnnotations); // TODO: REF // find annotation in referenced models }
protected override IEnumerable <IEdmDirectValueAnnotation> GetAttachedAnnotations(IEdmElement element) { CsdlSemanticsElement csdlElement = element as CsdlSemanticsElement; if (csdlElement != null) { return(csdlElement.DirectValueAnnotations); } return(Enumerable.Empty <IEdmDirectValueAnnotation>()); }
internal IEnumerable <IEdmVocabularyAnnotation> WrapInlineVocabularyAnnotations(CsdlSemanticsElement element, CsdlSemanticsSchema schema) { IEdmVocabularyAnnotatable vocabularyAnnotatableElement = element as IEdmVocabularyAnnotatable; if (vocabularyAnnotatableElement != null) { IEnumerable <CsdlAnnotation> vocabularyAnnotations = element.Element.VocabularyAnnotations; if (vocabularyAnnotations.FirstOrDefault() != null) { List <IEdmVocabularyAnnotation> wrappedAnnotations = new List <IEdmVocabularyAnnotation>(); foreach (CsdlAnnotation vocabularyAnnotation in vocabularyAnnotations) { IEdmVocabularyAnnotation vocabAnnotation = this.WrapVocabularyAnnotation(vocabularyAnnotation, schema, vocabularyAnnotatableElement, null, vocabularyAnnotation.Qualifier); vocabAnnotation.SetSerializationLocation(this, EdmVocabularyAnnotationSerializationLocation.Inline); wrappedAnnotations.Add(vocabAnnotation); } return(wrappedAnnotations); } } return(Enumerable.Empty <IEdmVocabularyAnnotation>()); }
/// <summary> /// Searches for vocabulary annotations specified by this model. /// </summary> /// <param name="element">The annotated element.</param> /// <returns>The vocabulary annotations for the element.</returns> public override IEnumerable <IEdmVocabularyAnnotation> FindDeclaredVocabularyAnnotations(IEdmVocabularyAnnotatable element) { // Include the inline annotations only if this model is the one that defined them. CsdlSemanticsReference semanticsReference = element as CsdlSemanticsReference; if (semanticsReference != null) { if (semanticsReference.Model == this) { return(semanticsReference.InlineVocabularyAnnotations); } else { return(Enumerable.Empty <IEdmVocabularyAnnotation>()); } } CsdlSemanticsInclude semanticsInclude = element as CsdlSemanticsInclude; if (semanticsInclude != null) { if (semanticsInclude.Model == this) { return(semanticsInclude.InlineVocabularyAnnotations); } else { return(Enumerable.Empty <IEdmVocabularyAnnotation>()); } } CsdlSemanticsElement semanticsElement = element as CsdlSemanticsElement; IEnumerable <IEdmVocabularyAnnotation> inlineAnnotations = semanticsElement != null && semanticsElement.Model == this ? semanticsElement.InlineVocabularyAnnotations : Enumerable.Empty <IEdmVocabularyAnnotation>(); if (this.outOfLineAnnotations.Count > 0) { List <CsdlSemanticsAnnotations> elementAnnotations; string fullName = semanticsElement != null?semanticsElement.GetAnnotationFullQualifiedName(element) : EdmUtil.FullyQualifiedName(element); if (fullName != null && this.outOfLineAnnotations.TryGetValue(fullName, out elementAnnotations)) { List <IEdmVocabularyAnnotation> result = new List <IEdmVocabularyAnnotation>(); foreach (CsdlSemanticsAnnotations annotations in elementAnnotations) { foreach (CsdlAnnotation annotation in annotations.Annotations.Annotations) { IEdmVocabularyAnnotation vocabAnnotation = this.WrapVocabularyAnnotation(annotation, annotations.Context, null, annotations, annotations.Annotations.Qualifier); vocabAnnotation.SetSerializationLocation(this, EdmVocabularyAnnotationSerializationLocation.OutOfLine); result.Add(vocabAnnotation); } } return(inlineAnnotations.Concat(result)); } } return(inlineAnnotations); // TODO: REF // find annotation in referenced models }