public IColorFileHandler <T> GetHandlerForFile(string sourceFile) { IColorFileHandler <T> result = null; bool oneFound = false; foreach (var handler in _handlers) { if (handler.Accepts(sourceFile)) { if (oneFound) { // multiple matches throw new Exception("More than one possible handler"); } result = handler; oneFound = true; } } return(result); }
public void Register(IColorFileHandler <T> handler) { _handlers.Add(handler); }
public ColorFileProcessor(IColorFileHandler <T> handler) { _handler = handler; }