Mongo.Context.MongoMetadata.RegisterArrayProperty C# (CSharp) Method

RegisterArrayProperty() private method

private RegisterArrayProperty ( MongoContext context, System.Data.Services.Providers.ResourceType collectionType, BsonElement element ) : void
context MongoContext
collectionType System.Data.Services.Providers.ResourceType
element BsonElement
return void
        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);
                        }
                    }
                }
            }
        }