private static IList <NavigationPropertyRestriction> GetRestrictedProperties(IEdmRecordExpression record)
        {
            if (record != null && record.Properties != null)
            {
                IEdmPropertyConstructor property = record.Properties.FirstOrDefault(p => p.Name == "RestrictedProperties");
                if (property != null)
                {
                    IEdmCollectionExpression value = property.Value as IEdmCollectionExpression;
                    if (value != null && value.Elements != null)
                    {
                        IList <NavigationPropertyRestriction> restrictedProperties = new List <NavigationPropertyRestriction>();
                        foreach (var item in value.Elements.OfType <IEdmRecordExpression>())
                        {
                            NavigationPropertyRestriction restriction = new NavigationPropertyRestriction();
                            restriction.Navigability       = item.GetEnum <NavigationType>("Navigability");
                            restriction.NavigationProperty = item.GetPropertyPath("NavigationProperty");
                            restrictedProperties.Add(restriction);
                        }

                        if (restrictedProperties.Any())
                        {
                            return(restrictedProperties);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        ///  Get the collection of <typeparamref name="T"/> from the record using the given property name.
        /// </summary>
        /// <typeparam name="T">The element type.</typeparam>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="elementAction">The element action.</param>
        /// <returns>The collection or null.</returns>
        public static IList <T> GetCollection <T>(this IEdmRecordExpression record, string propertyName, Action <T, IEdmExpression> elementAction)
            where T : new()
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);

            if (property != null)
            {
                IEdmCollectionExpression collection = property.Value as IEdmCollectionExpression;
                if (collection != null && collection.Elements != null)
                {
                    IList <T> items = new List <T>();
                    foreach (var item in collection.Elements)
                    {
                        T a = new T();
                        elementAction(a, item);
                        items.Add(a);
                    }

                    return(items);
                }
            }

            return(null);
        }
        /// <summary>
        /// Get the collection of property path from the record using the given property name.
        /// </summary>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The collection of property path or null.</returns>
        public static IList <string> GetCollectionPropertyPath(this IEdmRecordExpression record, string propertyName)
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            if (record.Properties != null)
            {
                IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);
                if (property != null)
                {
                    IEdmCollectionExpression value = property.Value as IEdmCollectionExpression;
                    if (value != null && value.Elements != null)
                    {
                        IList <string> properties = new List <string>();
                        foreach (var a in value.Elements.Select(e => e as IEdmPathExpression))
                        {
                            properties.Add(a.Path);
                        }

                        if (properties.Any())
                        {
                            return(properties);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Get the collection of string from the record using the given property name.
        /// </summary>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The collection of string or null.</returns>
        public static IList <string> GetCollection(this IEdmRecordExpression record, string propertyName)
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);

            if (property != null)
            {
                IEdmCollectionExpression collection = property.Value as IEdmCollectionExpression;
                if (collection != null && collection.Elements != null)
                {
                    IList <string> items = new List <string>();
                    foreach (var item in collection.Elements)
                    {
                        IEdmStringConstantExpression itemRecord = item as IEdmStringConstantExpression;
                        items.Add(itemRecord.Value);
                    }

                    return(items);
                }
            }

            return(null);
        }
        /// <summary>
        /// Init the <see cref="SearchRestrictionsType"/>.
        /// </summary>
        /// <param name="record">The input record.</param>
        public void Initialize(IEdmRecordExpression record)
        {
            Utils.CheckArgumentNull(record, nameof(record));

            // Searchable
            Searchable = record.GetBoolean("Searchable");

            // read the "UnsupportedExpressions"
            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == "UnsupportedExpressions");

            if (property != null)
            {
                IEdmEnumMemberExpression value = property.Value as IEdmEnumMemberExpression;
                if (value != null && value.EnumMembers != null)
                {
                    SearchExpressions result;
                    foreach (var v in value.EnumMembers)
                    {
                        if (Enum.TryParse(v.Name, out result))
                        {
                            if (UnsupportedExpressions == null)
                            {
                                UnsupportedExpressions = result;
                            }
                            else
                            {
                                UnsupportedExpressions = UnsupportedExpressions | result;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Get the Enum value from the record using the given property name.
        /// </summary>
        /// <typeparam name="T">The output enum type.</typeparam>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The Enum value or null.</returns>
        public static T?GetEnum <T>(this IEdmRecordExpression record, string propertyName)
            where T : struct
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            if (record.Properties != null)
            {
                IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);
                if (property != null)
                {
                    IEdmEnumMemberExpression value = property.Value as IEdmEnumMemberExpression;
                    if (value != null && value.EnumMembers != null && value.EnumMembers.Any())
                    {
                        IEdmEnumMember member = value.EnumMembers.First();
                        T result;
                        if (Enum.TryParse(member.Name, out result))
                        {
                            return(result);
                        }
                    }
                }
            }

            return(null);
        }
Example #7
0
        public static void SetSearchRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, bool searchable, CapabilitiesSearchExpressions unsupported)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (entitySet == null)
            {
                throw new ArgumentNullException("entitySet");
            }

            var target     = entitySet;
            var term       = SearchRestrictionsTerm;
            var name       = new EdmEnumTypeReference(SearchExpressionsType, false).ToStringLiteral((long)unsupported);
            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Searchable", new EdmBooleanConstant(searchable)),
                new EdmPropertyConstructor("UnsupportedExpressions", new EdmEnumMemberReferenceExpression(SearchExpressionsType.Members.Single(m => m.Name == name))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);

            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Example #8
0
        internal static bool TryAssertRecordAsType(this IEdmRecordExpression expression, IEdmTypeReference type, IEdmType context, bool matchExactly, out IEnumerable <EdmError> discoveredErrors)
        {
            EdmUtil.CheckArgumentNull(expression, "expression");
            EdmUtil.CheckArgumentNull(type, "type");

            if (!type.IsStructured())
            {
                discoveredErrors = new EdmError[] { new EdmError(expression.Location(), EdmErrorCode.RecordExpressionNotValidForNonStructuredType, Edm.Strings.EdmModel_Validator_Semantic_RecordExpressionNotValidForNonStructuredType) };
                return(false);
            }

            HashSetInternal <string> foundProperties = new HashSetInternal <string>();
            List <EdmError>          errors          = new List <EdmError>();

            IEdmStructuredTypeReference structuredType = type.AsStructured();

            foreach (IEdmProperty typeProperty in structuredType.StructuredDefinition().Properties())
            {
                IEdmPropertyConstructor expressionProperty = expression.Properties.FirstOrDefault(p => p.Name == typeProperty.Name);
                if (expressionProperty == null)
                {
                    errors.Add(new EdmError(expression.Location(), EdmErrorCode.RecordExpressionMissingRequiredProperty, Edm.Strings.EdmModel_Validator_Semantic_RecordExpressionMissingProperty(typeProperty.Name)));
                }
                else
                {
                    IEnumerable <EdmError> recursiveErrors;
                    if (!expressionProperty.Value.TryAssertType(typeProperty.Type, context, matchExactly, out recursiveErrors))
                    {
                        foreach (EdmError error in recursiveErrors)
                        {
                            errors.Add(error);
                        }
                    }

                    foundProperties.Add(typeProperty.Name);
                }
            }

            if (!structuredType.IsOpen())
            {
                foreach (IEdmPropertyConstructor property in expression.Properties)
                {
                    if (!foundProperties.Contains(property.Name))
                    {
                        errors.Add(new EdmError(expression.Location(), EdmErrorCode.RecordExpressionHasExtraProperties, Edm.Strings.EdmModel_Validator_Semantic_RecordExpressionHasExtraProperties(property.Name)));
                    }
                }
            }

            if (errors.FirstOrDefault() != null)
            {
                discoveredErrors = errors;
                return(false);
            }

            discoveredErrors = Enumerable.Empty <EdmError>();
            return(true);
        }
 internal void WritePropertyConstructorElementHeader(IEdmPropertyConstructor constructor, bool isInline)
 {
     this.xmlWriter.WriteStartElement("PropertyValue");
     this.WriteRequiredAttribute <string>("Property", constructor.Name, new Func <string, string>(EdmValueWriter.StringAsXml));
     if (isInline)
     {
         this.WriteInlineExpression(constructor.Value);
     }
 }
        private static IEnumerable <IScopesEvaluator> ExtractPermissionsFromProperty(IEdmPropertyConstructor permissionsProperty)
        {
            if (permissionsProperty?.Value is IEdmCollectionExpression permissionsValue)
            {
                return(permissionsValue.Elements.OfType <IEdmRecordExpression>().Select(p => GetPermissionData(p)));
            }

            return(Enumerable.Empty <PermissionData>());
        }
 internal void WritePropertyConstructorElementHeader(IEdmPropertyConstructor constructor, bool isInline)
 {
     this.xmlWriter.WriteStartElement(CsdlConstants.Element_PropertyValue);
     this.WriteRequiredAttribute(CsdlConstants.Attribute_Property, constructor.Name, EdmValueWriter.StringAsXml);
     if (isInline)
     {
         this.WriteInlineExpression(constructor.Value);
     }
 }
        protected override void ProcessPropertyConstructor(IEdmPropertyConstructor constructor)
        {
            bool isInline = IsInlineExpression(constructor.Value);

            this.BeginElement <IEdmPropertyConstructor>(constructor, t => this.schemaWriter.WritePropertyConstructorElementHeader(t, isInline), new Action <IEdmPropertyConstructor> [0]);
            if (!isInline)
            {
                base.ProcessPropertyConstructor(constructor);
            }
            this.EndElement(constructor);
        }
Example #13
0
        /// <summary>
        /// Init the <see cref="ResourceExampleValue"/>
        /// </summary>
        /// <param name="record">The input record.</param>
        public override void Initialize(IEdmRecordExpression record)
        {
            // Load ExampleValue
            base.Initialize(record);

            // Value of PrimitiveExampleValue
            IEdmPropertyConstructor property = record.FindProperty("Value");

            if (property != null)
            {
                Value = property.Value.Convert() as ODataResourceValue;
            }
        }
        /// <summary>
        /// Get the collection of <typeparamref name="T"/> from the record using the given property name.
        /// </summary>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="elementFunc">The element func.</param>
        /// <returns>The collection of string or null.</returns>
        public static IEnumerable <T> GetCollection <T>(this IEdmRecordExpression record, string propertyName, Func <IEdmExpression, T> elementFunc)
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);

            if (property != null)
            {
                IEdmCollectionExpression collection = property.Value as IEdmCollectionExpression;
                if (collection != null && collection.Elements != null)
                {
                    return(collection.Elements.Select(e => elementFunc(e)));
                }
            }

            return(null);
        }
Example #15
0
        private static void SetCapabilitiesAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IEdmValueTerm term, bool value, IEnumerable <IEdmNavigationProperty> navigationProperties, string name1, string name2)
        {
            if (navigationProperties == null)
            {
                navigationProperties = new IEdmNavigationProperty[0];
            }

            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor(name1, new EdmBooleanConstant(value)),
                new EdmPropertyConstructor(name2, new EdmCollectionExpression(navigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);

            annotation.SetSerializationLocation(model, target.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Example #16
0
        protected override bool Initialize(IEdmVocabularyAnnotation annotation)
        {
            if (annotation == null ||
                annotation.Value == null ||
                annotation.Value.ExpressionKind != EdmExpressionKind.Record)
            {
                return(false);
            }

            IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;

            // Searchable
            Searchable = record.GetBoolean("Searchable");

            // read the "UnsupportedExpressions"
            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == "UnsupportedExpressions");

            if (property != null)
            {
                IEdmEnumMemberExpression value = property.Value as IEdmEnumMemberExpression;
                if (value != null && value.EnumMembers != null)
                {
                    SearchExpressions result;
                    foreach (var v in value.EnumMembers)
                    {
                        if (Enum.TryParse(v.Name, out result))
                        {
                            if (UnsupportedExpressions == null)
                            {
                                UnsupportedExpressions = result;
                            }
                            else
                            {
                                UnsupportedExpressions = UnsupportedExpressions | result;
                            }
                        }
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Get the boolean value from the record using the given property name.
        /// </summary>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The boolean value or null.</returns>
        public static bool?GetBoolean(this IEdmRecordExpression record, string propertyName)
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            if (record.Properties != null)
            {
                IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);
                if (property != null)
                {
                    IEdmBooleanConstantExpression value = property.Value as IEdmBooleanConstantExpression;
                    if (value != null)
                    {
                        return(value.Value);
                    }
                }
            }

            return(null);
        }
Example #18
0
        /// <summary>
        ///  Get the collection of <typeparamref name="T"/> from the record using the given property name.
        /// </summary>
        /// <typeparam name="T">The element type.</typeparam>
        /// <param name="record">The record expression.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The collection or null.</returns>
        public static T GetRecord <T>(this IEdmRecordExpression record, string propertyName)
            where T : IRecord, new()
        {
            Utils.CheckArgumentNull(record, nameof(record));
            Utils.CheckArgumentNull(propertyName, nameof(propertyName));

            IEdmPropertyConstructor property = record.Properties.FirstOrDefault(e => e.Name == propertyName);

            if (property != null)
            {
                IEdmRecordExpression recordValue = property.Value as IEdmRecordExpression;
                if (recordValue != null)
                {
                    T a = new T();
                    a.Initialize(recordValue);
                    return(a);
                }
            }

            return(default);
        /// <summary>
        /// Init the <see cref="PrimitiveExampleValue"/>
        /// </summary>
        /// <param name="record">The input record.</param>
        public override void Initialize(IEdmRecordExpression record)
        {
            Utils.CheckArgumentNull(record, nameof(record));

            /* Should we throw exception if the input record is not a primitive example value?
             * Leave the below codes for further decision.
             * if (record.DeclaredType == null || record.DeclaredType.FullName() != "Org.OData.Core.V1.PrimitiveExampleValue")
             * {
             *  throw new OpenApiException();
             * }
             */

            // Load ExampleValue
            base.Initialize(record);

            // Value of PrimitiveExampleValue
            IEdmPropertyConstructor property = record.FindProperty("Value");

            if (property != null)
            {
                Value = property.Value.Convert() as ODataPrimitiveValue;
            }
        }
 internal abstract void WritePropertyConstructorElementEnd(IEdmPropertyConstructor constructor);
Example #21
0
		public EdmRecordExpression(IEdmStructuredTypeReference declaredType, IEdmPropertyConstructor[] properties) : this(declaredType, (IEnumerable<IEdmPropertyConstructor>)properties)
		{
		}
Example #22
0
        internal static bool TryAssertRecordAsType(this IEdmRecordExpression expression, IEdmTypeReference type, out IEnumerable <EdmError> discoveredErrors)
        {
            IEnumerable <EdmError> edmErrors = null;

            EdmUtil.CheckArgumentNull <IEdmRecordExpression>(expression, "expression");
            EdmUtil.CheckArgumentNull <IEdmTypeReference>(type, "type");
            if (type.IsStructured())
            {
                HashSetInternal <string>    strs       = new HashSetInternal <string>();
                List <EdmError>             edmErrors1 = new List <EdmError>();
                IEdmStructuredTypeReference edmStructuredTypeReference = type.AsStructured();
                IEnumerator <IEdmProperty>  enumerator = edmStructuredTypeReference.StructuredDefinition().Properties().GetEnumerator();
                using (enumerator)
                {
                    Func <IEdmPropertyConstructor, bool> func = null;
                    while (enumerator.MoveNext())
                    {
                        IEdmProperty current = enumerator.Current;
                        IEnumerable <IEdmPropertyConstructor> properties = expression.Properties;
                        if (func == null)
                        {
                            func = (IEdmPropertyConstructor p) => p.Name == current.Name;
                        }
                        IEdmPropertyConstructor edmPropertyConstructor = properties.FirstOrDefault <IEdmPropertyConstructor>(func);
                        if (edmPropertyConstructor != null)
                        {
                            if (!edmPropertyConstructor.Value.TryAssertType(current.Type, out edmErrors))
                            {
                                IEnumerator <EdmError> enumerator1 = edmErrors.GetEnumerator();
                                using (enumerator1)
                                {
                                    while (enumerator1.MoveNext())
                                    {
                                        EdmError edmError = enumerator1.Current;
                                        edmErrors1.Add(edmError);
                                    }
                                }
                            }
                            strs.Add(current.Name);
                        }
                        else
                        {
                            edmErrors1.Add(new EdmError(expression.Location(), EdmErrorCode.RecordExpressionMissingRequiredProperty, Strings.EdmModel_Validator_Semantic_RecordExpressionMissingProperty(current.Name)));
                        }
                    }
                }
                if (!edmStructuredTypeReference.IsOpen())
                {
                    foreach (IEdmPropertyConstructor property in expression.Properties)
                    {
                        if (strs.Contains(property.Name))
                        {
                            continue;
                        }
                        edmErrors1.Add(new EdmError(expression.Location(), EdmErrorCode.RecordExpressionHasExtraProperties, Strings.EdmModel_Validator_Semantic_RecordExpressionHasExtraProperties(property.Name)));
                    }
                }
                if (edmErrors1.FirstOrDefault <EdmError>() == null)
                {
                    discoveredErrors = Enumerable.Empty <EdmError>();
                    return(true);
                }
                else
                {
                    discoveredErrors = edmErrors1;
                    return(false);
                }
            }
            else
            {
                EdmError[] edmErrorArray = new EdmError[1];
                edmErrorArray[0] = new EdmError(expression.Location(), EdmErrorCode.RecordExpressionNotValidForNonStructuredType, Strings.EdmModel_Validator_Semantic_RecordExpressionNotValidForNonStructuredType);
                discoveredErrors = edmErrorArray;
                return(false);
            }
        }
 internal abstract void WritePropertyValueElementHeader(IEdmPropertyConstructor value, bool isInline);
 internal abstract void WritePropertyConstructorElementHeader(IEdmPropertyConstructor constructor, bool isInline);
 internal override void WritePropertyConstructorElementEnd(IEdmPropertyConstructor constructor)
 {
     this.WriteEndElement();
 }
Example #26
0
 protected virtual void ProcessPropertyConstructor(IEdmPropertyConstructor constructor)
 {
     this.VisitExpression(constructor.Value);
 }
Example #27
0
		public EdmRecordExpression(IEdmPropertyConstructor[] properties) : this((IEnumerable<IEdmPropertyConstructor>)properties)
		{
		}
 public DelayedRecordProperty(DelayedExpressionContext context, IEdmPropertyConstructor constructor)
     : base(context)
 {
     this.constructor = constructor;
 }
Example #29
0
        public static void SetSearchRestrictionsCapabilitiesAnnotation(this EdmModel model, IEdmEntitySet entitySet, bool searchable, CapabilitiesSearchExpressions unsupported)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (entitySet == null) throw new ArgumentNullException("entitySet");

            var target = entitySet;
            var term = SearchRestrictionsTerm;
            var name = new EdmEnumTypeReference(SearchExpressionsType, false).ToStringLiteral((long)unsupported);
            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor("Searchable", new EdmBooleanConstant(searchable)),
                new EdmPropertyConstructor("UnsupportedExpressions", new EdmEnumMemberReferenceExpression(SearchExpressionsType.Members.Single(m => m.Name == name))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);
            annotation.SetSerializationLocation(model, entitySet.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Example #30
0
        private static void SetCapabilitiesAnnotation(this EdmModel model, IEdmVocabularyAnnotatable target, IEdmValueTerm term, bool value, IEnumerable<IEdmNavigationProperty> navigationProperties, string name1, string name2)
        {
            if (navigationProperties == null)
            {
                navigationProperties = new IEdmNavigationProperty[0];
            }

            var properties = new IEdmPropertyConstructor[]
            {
                new EdmPropertyConstructor(name1, new EdmBooleanConstant(value)),
                new EdmPropertyConstructor(name2, new EdmCollectionExpression(navigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)))),
            };
            var record = new EdmRecordExpression(properties);

            var annotation = new EdmAnnotation(target, term, record);
            annotation.SetSerializationLocation(model, target.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
        private void ValidateAnnotationProperty(IEdmModel model, IEdmProperty actualProperty, IEdmPropertyConstructor annotationProperty, Action<IEdmModel, IEdmStructuredType, IEnumerable<IEdmPropertyConstructor>> validateAnnotation)
        {
            if (annotationProperty.Value.ExpressionKind.Equals(EdmExpressionKind.Record))
            {
                if (IsPropertyNonNullExpressionOrNonNullable(actualProperty.Type.IsNullable, annotationProperty.Value.ExpressionKind))
                {
                    var actualPropertyType = model.FindType(actualProperty.Type.Definition.ToString()) as IEdmStructuredType;
                    var annotationPropertyValue = (annotationProperty.Value as IEdmRecordExpression).Properties;

                    validateAnnotation(model, actualPropertyType, annotationPropertyValue);
                }
            }
            else if (annotationProperty.Value.ExpressionKind.Equals(EdmExpressionKind.Collection))
            {
                var actualPropertyElementType = (actualProperty.Type.Definition as IEdmCollectionType).ElementType;
                var actualElementExpressionKind = this.GetPrimitiveExpressionKind(actualPropertyElementType.Definition.ToString());
                var annotationPropertyElements = (annotationProperty.Value as IEdmCollectionExpression).Elements;

                foreach (var element in annotationPropertyElements)
                {
                    if (IsPropertyNonNullExpressionOrNonNullable(actualPropertyElementType.IsNullable, element.ExpressionKind))
                    {
                        Assert.AreEqual(actualElementExpressionKind, element.ExpressionKind, "Invalid expression kind.");
                    }
                }
            }
            else
            {
                var actualPropertyType = this.GetPrimitiveExpressionKind(actualProperty.Type.Definition.ToString());

                if (IsPropertyNonNullExpressionOrNonNullable(actualProperty.Type.IsNullable, annotationProperty.Value.ExpressionKind))
                {
                    Assert.AreEqual(actualPropertyType, annotationProperty.Value.ExpressionKind, "Invalid expression kind.");
                }
            }
        }