private void CheckValidity()
{
if (this.Status != RunStatus.NotStarted)
{
throw new InvalidOperationException("You cannot restart a stopped flow");
}
//Zijn er stream die niet aan beide kanten vast zitten?
foreach (BoundedBlockingQueue stream in this.Streams)
{
int n = this.Nodes.Where(node => node.StreamIn == stream).Count();
if (n == 0)
{
throw new InvalidOperationException(String.Format("The stream '{0}' is not connected to any input generator", stream.Name));
}
QueueEqualityComparer comp = new QueueEqualityComparer();
n = (from node in this.Nodes where node.OutQueues.Contains(stream, comp) select node).Count();
if (n == 0)
{
throw new InvalidOperationException(String.Format("The stream '{0}' is not connected to any output consumer", stream.Name));
}
}
foreach (var node in Nodes)
{
Type[] genericParams = node.GetType().GetGenericArguments();
if (genericParams.Length > 0)
{
if (node.OutQueues.Length == genericParams.Length - 1)
{
// We use the in stream
if (node.StreamIn == null)
{
throw new InvalidOperationException(String.Format("The node '{0}' needs an in-connection", node.Name));
}
}
}
}
}