public PathState GetPathState(Game game, FileManager fileManager, string path)
{
if (game == null)
throw new ArgumentNullException("game");
if (fileManager == null)
throw new ArgumentNullException("fileManager");
var id = Aggregate.Create(fileManager.Id, game, path);
PathState state;
path = path.Replace('\\', '/');
if (!PathStates.TryGetValue(id, out state)) {
Type stateType = game.StateType;
if (stateType == null)
throw new ArgumentException(string.Format("The game {0} does not have an accepted {1} state type.", game, typeof(State).Name));
ConstructorInfo constructor = stateType.GetConstructor(new Type[] { typeof(AlexandriaManager), typeof(string), typeof(FileManager) });
if (constructor == null)
throw new Exception(string.Format("State type {0} does not have an appropriate constructor, like the one for {1}.", stateType.FullName, typeof(State).FullName));
state = (PathState)constructor.Invoke(new object[] { this, path, fileManager });
PathStates[id] = state;
}
return state;
}