in src/Readers/Vipr.Reader.OData.v4/Capabilities/CapabilityAnnotationParser.cs [86:127]
private void ParseCollection(OdcmObject odcmObject, IEdmCollectionExpression collectionExpression, string annotationTerm)
{
if (!collectionExpression.Elements.Any())
{
return;
}
var elementExpression = collectionExpression.Elements.First();
var recordExpression = elementExpression as IEdmRecordExpression;
if (recordExpression != null)
{
if (recordExpression.Properties.Count(p => p.Value is IEdmPathExpression) == 1)
{
// We assume that if a collection element is a record with a single path expression, the rest
// of record properties should be associated with this path expression
// (e.g. NavigationRestrictions/RestrictedProperties).
ParsePropertyCollection(odcmObject, collectionExpression, annotationTerm);
}
else
{
var records = ParseRecordCollection(collectionExpression);
SetListCapability(odcmObject, records, annotationTerm);
}
}
else if (elementExpression is IEdmStringConstantExpression)
{
var strings = collectionExpression.Elements.Select(e => (e as IEdmStringConstantExpression).Value);
SetListCapability(odcmObject, strings, annotationTerm);
}
else if (elementExpression is IEdmPathExpression)
{
foreach (IEdmPathExpression expression in collectionExpression.Elements)
{
SetPathCapability(odcmObject, expression, annotationTerm);
}
}
else
{
Logger.Warn($"Unsupported collection of kind {elementExpression.ExpressionKind.ToString()} for Term \"{annotationTerm}\"");
}
}