public void Traverse(String directoryName, ITraversalHandler handler) { if (handler.ShouldTraverseDirectory(directoryName)) { handler.ProcessEntry(new TraversalEntry() { Info = new DirectoryInfo(directoryName) }); try { foreach (var fileNameString in Sort(Directory.GetFiles(directoryName))) { cancellationToken.ThrowIfCancellationRequested(); handler.ProcessEntry(new TraversalEntry() { Info = new FileInfo(fileNameString) }); } } catch(OperationCanceledException) { throw; } catch (Exception ex) { handler.HandleException(directoryName, ex); } try { foreach (var subDirectoryName in Sort(Directory.GetDirectories(directoryName))) { Traverse(subDirectoryName, handler); } } catch (Exception ex) { handler.HandleException(directoryName, ex); } } }
public bool CanMovePlayer(Vector3 position, Vector2 direction) { var hit = Physics2D.Raycast(position, direction, 1f); if (hit.collider == null) { return(true); } ITraversalHandler traversalHandler = null; if (_handlers.TryGetValue(hit.collider.tag, out traversalHandler)) { return(traversalHandler.Hit(hit.collider.gameObject)); } return(true); }