I'm working on making a shortcut... manager, if you will. It will be reused throughout the rest of the application for registering types that can later be resolved into views. I have a rule that the shortcuts need to be able to be grouped by their different purposes throughout the application. For instance, if I have shortcuts for car related stuff and then shortcuts for truck related stuff I would need them sorted.
This is what I have come up thus far. Thoughts, comments, and suggestions on changing this to make it better would be appreciated.
public static Shortcuts
{
public enum ShortcutType
{
Car, Truck
}
static Shortcuts
{
AllShortcuts = new Dictionary<string, Type>();
CarShortcuts = new Dictionary<string, Type>();
TruckShortcuts = new Dictionary<string, Type>();
}
public static Dictionary<string, Type> AllShortcuts { get; private set; }
public static Dictionary<string, Type> CarShortcuts { get; private set; }
public static Dictionary<string, Type> TruckShortcuts { get; private set; }
public static void AddShortcut(KeyValuePair<string, Type> kvp, ShortcutType type)
{
switch(type)
{
case ShortcutType.Car:
CarShortcuts.Add(kvp.Key, kvp.Value);
break;
case ShortcutType.Truck:
TruckShortcuts.Add(kvp.Key, kvp.Value);
break;
}
if (!AllShortcuts.Contains(kvp))
{
AllShortcuts.Add(kvp.Key, kvp.Value);
}
}
public static void RemoveShortcut(KeyValuePair<string, Type> kvp, ShortcutType type)
{
switch(type)
{
case ShortcutType.Car:
if (CarShortcuts.Contains(kvp))
{
CarShortcuts.Remove(kvp.Key);
}
break;
case ShortcutType.Truck:
if (TruckShortcuts.Contains(kvp))
{
TruckShortcuts.Remove(kvp.Key);
}
break;
}
if (AllShortcuts.Contains(kvp))
{
AllShortcuts.Remove(kvp.Key);
}
}
}