public void Do <O>(CanDoOperation <O> canDoOperation, DoOperation <O> doOperation) where O : class { foreach (var candidate in Values <O>().Where(candidate => canDoOperation(candidate))) { doOperation(candidate); return; } throw new ApplicationException(string.Format("No default for {0}", typeof(T).Name)); }
public void Do <O>(CanDoOperation <O> canDoOperation, DoOperation <O> doOperation) where O : class { for (int priority = operators.Count - 1; priority >= 0; priority--) { for (int i = operators[priority].Count - 1; i >= 0; i--) { Operator <T, P> anOperator = operators[priority][i]; anOperator.Processor = Processor; var candidate = anOperator as O; if (candidate == null) { continue; } if (!canDoOperation(candidate)) { continue; } doOperation(candidate); return; } } throw new ApplicationException(string.Format("No default for {0}", typeof(T).Name)); }