public AMovingItem GetUser(Farming userId) { AMovingItem outValue = null; this.listUsers.TryGetValue(userId, out outValue); return(outValue); }
private AMovingItem MyFactory(Farming userId) { AMovingItem returnValue = null; if (userId == Farming.Farmer) { returnValue = new Farmer(this.listUsers); } else if (actions.ContainsKey(userId)) { returnValue = actions[userId](); } return(returnValue); }
public void Run() { // start all threads this.StartThreads(); Thread.Sleep(500); Console.WriteLine(); // Get the list of actions to perform var parameters = Orchestrator.GetAction(); // Run each action foreach (var parameter in parameters) { AMovingItem with; this.listUsers.TryGetValue(parameter.With, out with); Console.WriteLine("Processing action to {0}, with {1}", this.listUsers[parameter.To], with); // Creation de l'action AMovingItem user = null; if (this.listUsers.TryGetValue(parameter.To, out user)) { ActionDetail action = new ActionDetail( (a, b) => a.Move(b), parameter ); // Set the action to run user.ActionToDo = action; // Wait for the action to end action.EndEvent.WaitOne(); } else { Console.WriteLine("Unknown user !"); } Console.WriteLine(); } // end all threads this.EndThreads(); }
public void AddPrey(AMovingItem prey) { this.listPrey.AddLast(prey); }