using System; using System.Collections.Generic; using SlatedGameToolkit.Tools.System.Interaction; namespace SlatedGameToolkit.Tools.System { public class CommandMap { Dictionary invocations; public IInvocable this[string invocation] { get { IInvocable result = null; invocations.TryGetValue(invocation, out result); return result; } } public CommandMap(params IInvocable[] invokables) { invocations = new Dictionary(); foreach (IInvocable item in invokables) { string[] invokers = item.GetInvokers(); foreach (string invoker in invokers) { try { invocations.Add(invoker, item); } catch (ArgumentException e) { throw new ArgumentException("A duplicate invocation string was found!", e); } } } } } }