Exemplo n.º 1
0
        internal AggregateContainsRelationCollectionSpan(AggregateContainsRelationCollection parent, IRelation relation)
        {
            Requires.NotNull(parent, nameof(parent));
            Requires.NotNull(relation, nameof(relation));

            _parent  = parent;
            Relation = relation;
        }
Exemplo n.º 2
0
        bool IRelatableItem.TryGetOrCreateContainsCollection(
            IRelationProvider relationProvider,
            [NotNullWhen(returnValue: true)] out AggregateContainsRelationCollection?relationCollection)
        {
            if (_containsCollection == null && AggregateContainsRelationCollection.TryCreate(this, relationProvider, out AggregateContainsRelationCollection? collection))
            {
                _containsCollection = collection;
            }

            relationCollection = _containsCollection;
            return(relationCollection != null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to create a collection for the children of <paramref name="parentItem"/>.
        /// Fails only when no relations exist to produce child items for the given item's type.
        /// </summary>
        public static bool TryCreate(IRelatableItem parentItem, IRelationProvider relationProvider, [NotNullWhen(returnValue: true)] out AggregateContainsRelationCollection?collection)
        {
            ImmutableArray <IRelation> containsRelations = relationProvider.GetContainsRelationsFor(parentItem.GetType());

            if (containsRelations.IsEmpty)
            {
                collection = null;
                return(false);
            }

            collection = new AggregateContainsRelationCollection(parentItem, containsRelations);
            return(true);
        }