protected virtual bool CheckChildCanGenerate(EntityContext child, EntityContext parent, bool onlyCheckCanGenerate) { Type typeToFlush = parent.Type; RequiredEntity requiredParent = child.Description.Required.First(x => x.Type == typeToFlush); ISpreadStrategy spreadStrategy = _generatorSetup.GetSpreadStrategy(child.Description, requiredParent); //check if child can still use parent entities from temporary storage to generate bool canGenerateMore = spreadStrategy.CanGenerateFromParentNextReleaseCount(parent, child); if (onlyCheckCanGenerate) { return(canGenerateMore); } //check if child is not a flush candidate itself bool childIsFlushCandidate = _flushCandidates.Contains(child); return(!childIsFlushCandidate && canGenerateMore); }
internal virtual ISpreadStrategy GetSpreadStrategy(IEntityDescription entityDescription, RequiredEntity requiredEntity) { if (requiredEntity.SpreadStrategy != null) { return(requiredEntity.SpreadStrategy); } if (DefaultSpreadStrategy != null) { return(DefaultSpreadStrategy); } throw new NullReferenceException($"Type {entityDescription.Type.FullName} for required entity {requiredEntity.Type} did not have an {nameof(ISpreadStrategy)} configured and {nameof(DefaultSpreadStrategy)} also was not provided."); }