/// <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 (CsdlVocabularyAnnotationBase annotation in annotations.Annotations.Annotations) { result.Add(this.WrapVocabularyAnnotation(annotation, annotations.Context, null, annotations, annotations.Annotations.Qualifier)); } } return(inlineAnnotations.Concat(result)); } return(inlineAnnotations); }
private IEnumerable <string> ComputePrincipalKeyPropertiesNotFoundInPrincipalProperties() { List <string> strs = null; IEnumerator <IEdmStructuralProperty> enumerator = this.PrincipalEnd.EntityType.Key().GetEnumerator(); using (enumerator) { Func <CsdlPropertyReference, bool> func = null; while (enumerator.MoveNext()) { IEdmStructuralProperty current = enumerator.Current; CsdlReferentialConstraintRole principal = this.constraint.Principal; IEnumerable <CsdlPropertyReference> properties = principal.Properties; if (func == null) { func = (CsdlPropertyReference reference) => reference.PropertyName == current.Name; } CsdlPropertyReference csdlPropertyReference = properties.Where <CsdlPropertyReference>(func).FirstOrDefault <CsdlPropertyReference>(); if (csdlPropertyReference != null) { continue; } strs = CsdlSemanticsElement.AllocateAndAdd <string>(strs, current.Name); } } List <string> strs1 = strs; IEnumerable <string> strs2 = strs1; if (strs1 == null) { strs2 = Enumerable.Empty <string>(); } return(strs2); }
protected override IEnumerable <IEdmDirectValueAnnotation> GetAttachedAnnotations(IEdmElement element) { CsdlSemanticsElement csdlElement = element as CsdlSemanticsElement; if (csdlElement != null) { return(csdlElement.DirectValueAnnotations); } return(Enumerable.Empty <IEdmDirectValueAnnotation>()); }
private IEnumerable <EdmError> ComputeErrors() { List <EdmError> edmErrors = null; if (this.EntityType as UnresolvedEntityType != null) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, this.EntityType.Errors()); } List <EdmError> edmErrors1 = edmErrors; IEnumerable <EdmError> edmErrors2 = edmErrors1; if (edmErrors1 == null) { edmErrors2 = Enumerable.Empty <EdmError>(); } return(edmErrors2); }
private IEnumerable <EdmError> ComputeErrors() { List <EdmError> edmErrors = null; IEdmEntityType entityType = this.PrincipalEnd.EntityType; CsdlReferentialConstraintRole principal = this.constraint.Principal; CsdlReferentialConstraintRole dependent = this.constraint.Dependent; if (this.constraint.Principal.Role == this.constraint.Dependent.Role) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.SameRoleReferredInReferentialConstraint, Strings.EdmModel_Validator_Semantic_SameRoleReferredInReferentialConstraint(this.constraint.Principal.Role))); } if (this.constraint.Dependent.Role != this.context.End1.Name && this.constraint.Dependent.Role != this.context.End2.Name) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidRoleInRelationshipConstraint, Strings.CsdlParser_InvalidEndRoleInRelationshipConstraint(this.constraint.Dependent.Role, this.context.Name))); } if (this.constraint.Principal.Role != this.context.End1.Name && this.constraint.Principal.Role != this.context.End2.Name) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidRoleInRelationshipConstraint, Strings.CsdlParser_InvalidEndRoleInRelationshipConstraint(this.constraint.Principal.Role, this.context.Name))); } if (edmErrors == null) { if (principal.Properties.Count <CsdlPropertyReference>() != dependent.Properties.Count <CsdlPropertyReference>()) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.MismatchNumberOfPropertiesInRelationshipConstraint, Strings.EdmModel_Validator_Semantic_MismatchNumberOfPropertiesinRelationshipConstraint)); } if (entityType.Key().Count <IEdmStructuralProperty>() != principal.Properties.Count <CsdlPropertyReference>() || this.PrincipalKeyPropertiesNotFoundInPrincipalProperties.Count <string>() != 0) { string str = Strings.EdmModel_Validator_Semantic_InvalidPropertyInRelationshipConstraintPrimaryEnd(string.Concat(this.DependentEnd.DeclaringAssociation.Namespace, (char)46, this.DependentEnd.DeclaringAssociation.Name), this.constraint.Principal.Role); edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.BadPrincipalPropertiesInReferentialConstraint, str)); } foreach (string dependentPropertiesNotFoundInDependentType in this.DependentPropertiesNotFoundInDependentType) { string str1 = Strings.EdmModel_Validator_Semantic_InvalidPropertyInRelationshipConstraintDependentEnd(dependentPropertiesNotFoundInDependentType, this.constraint.Dependent.Role); edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(base.Location, EdmErrorCode.InvalidPropertyInRelationshipConstraint, str1)); } } List <EdmError> edmErrors1 = edmErrors; IEnumerable <EdmError> edmErrors2 = edmErrors1; if (edmErrors1 == null) { edmErrors2 = Enumerable.Empty <EdmError>(); } return(edmErrors2); }
private IEnumerable <EdmError> ComputeErrors() { List <EdmError> edmErrors = null; if (this.Association as UnresolvedAssociation != null) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, this.Association.Errors()); } if (this.End1.Role != null && this.End2.Role != null && this.End1.Role.Name == this.End2.Role.Name) { edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors, new EdmError(this.End2.Location(), EdmErrorCode.InvalidName, Strings.EdmModel_Validator_Semantic_DuplicateEndName(this.End1.Role.Name))); } List <EdmError> edmErrors1 = edmErrors; IEnumerable <EdmError> edmErrors2 = edmErrors1; if (edmErrors1 == null) { edmErrors2 = Enumerable.Empty <EdmError>(); } return(edmErrors2); }
public override IEnumerable <IEdmVocabularyAnnotation> FindDeclaredVocabularyAnnotations(IEdmVocabularyAnnotatable element) { List <CsdlSemanticsAnnotations> list; CsdlSemanticsElement element2 = element as CsdlSemanticsElement; IEnumerable <IEdmVocabularyAnnotation> first = ((element2 != null) && (element2.Model == this)) ? element2.InlineVocabularyAnnotations : Enumerable.Empty <IEdmVocabularyAnnotation>(); string key = EdmUtil.FullyQualifiedName(element); if ((key == null) || !this.outOfLineAnnotations.TryGetValue(key, out list)) { return(first); } List <IEdmVocabularyAnnotation> second = new List <IEdmVocabularyAnnotation>(); foreach (CsdlSemanticsAnnotations annotations in list) { foreach (CsdlVocabularyAnnotationBase base2 in annotations.Annotations.Annotations) { second.Add(this.WrapVocabularyAnnotation(base2, annotations.Context, null, annotations, annotations.Annotations.Qualifier)); } } return(first.Concat <IEdmVocabularyAnnotation>(second)); }
private IEnumerable <string> ComputeDependentPropertiesNotFoundInDependentType() { List <string> strs = new List <string>(); IEdmEntityType entityType = this.DependentEnd.EntityType; foreach (CsdlPropertyReference property in this.constraint.Dependent.Properties) { if (entityType.FindProperty(property.PropertyName) != null) { continue; } strs = CsdlSemanticsElement.AllocateAndAdd <string>(strs, property.PropertyName); } List <string> strs1 = strs; IEnumerable <string> strs2 = strs1; if (strs1 == null) { strs2 = Enumerable.Empty <string>(); } return(strs2); }
private IEnumerable <EdmError> ComputeErrors() { List <EdmError> edmErrors = null; if (this.association.End1.Name == this.association.End2.Name) { List <EdmError> edmErrors1 = edmErrors; EdmLocation location = this.association.End2.Location; EdmLocation edmLocation = location; if (location == null) { edmLocation = base.Location; } edmErrors = CsdlSemanticsElement.AllocateAndAdd <EdmError>(edmErrors1, new EdmError(edmLocation, EdmErrorCode.AlreadyDefined, Strings.EdmModel_Validator_Semantic_EndNameAlreadyDefinedDuplicate(this.association.End1.Name))); } List <EdmError> edmErrors2 = edmErrors; IEnumerable <EdmError> edmErrors3 = edmErrors2; if (edmErrors2 == null) { edmErrors3 = Enumerable.Empty <EdmError>(); } return(edmErrors3); }
internal IEnumerable <IEdmVocabularyAnnotation> WrapInlineVocabularyAnnotations(CsdlSemanticsElement element, CsdlSemanticsSchema schema) { IEdmVocabularyAnnotatable vocabularyAnnotatableElement = element as IEdmVocabularyAnnotatable; if (vocabularyAnnotatableElement != null) { IEnumerable <CsdlVocabularyAnnotationBase> vocabularyAnnotations = element.Element.VocabularyAnnotations; if (vocabularyAnnotations.FirstOrDefault() != null) { List <IEdmVocabularyAnnotation> wrappedAnnotations = new List <IEdmVocabularyAnnotation>(); foreach (CsdlVocabularyAnnotationBase 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>()); }
internal IEnumerable <IEdmVocabularyAnnotation> WrapInlineVocabularyAnnotations(CsdlSemanticsElement element, CsdlSemanticsSchema schema) { IEdmVocabularyAnnotatable targetContext = element as IEdmVocabularyAnnotatable; if (targetContext != null) { IEnumerable <CsdlVocabularyAnnotationBase> vocabularyAnnotations = element.Element.VocabularyAnnotations; if (vocabularyAnnotations.FirstOrDefault <CsdlVocabularyAnnotationBase>() != null) { List <IEdmVocabularyAnnotation> list = new List <IEdmVocabularyAnnotation>(); foreach (CsdlVocabularyAnnotationBase base2 in vocabularyAnnotations) { IEdmVocabularyAnnotation annotation = this.WrapVocabularyAnnotation(base2, schema, targetContext, null, base2.Qualifier); annotation.SetSerializationLocation(this, 0); list.Add(annotation); } return(list); } } return(Enumerable.Empty <IEdmVocabularyAnnotation>()); }