private void RegisterArrayProperty(MongoContext context, ResourceType collectionType, BsonElement element)
{
var propertyName = GetResourcePropertyName(element, ResourceTypeKind.EntityType);
var bsonArray = element.Value.AsBsonArray;
if (bsonArray != null)
{
foreach (var arrayValue in bsonArray)
{
if (arrayValue.AsBsonValue == BsonNull.Value)
continue;
if (arrayValue.BsonType == BsonType.Document)
{
RegisterDocumentProperties(context, collectionType, new BsonElement(element.Name, arrayValue));
}
else if (ResolveResourceProperty(collectionType, propertyName) == null)
{
// OData protocol doesn't support collections of collections
if (arrayValue.BsonType != BsonType.Array)
{
var mappedType = BsonTypeMapper.MapToDotNetValue(arrayValue).GetType();
this.instanceMetadataCache.AddCollectionProperty(collectionType, propertyName, mappedType);
}
}
}
}
}