I think you should probably write your wrapper class according to your needs. I mean, if you need to store a dictionary of pre-made lists, Dictionary<int, List<type>>
should be fine as long as it's only a private property. You should not expose it though publicly as obviously it exposes too much information and you cannot cast it to IDictionary<int, IList<T>>
or something similar because of the lack of covariance.
Your best bet would be something like that:
class MyWrapper<T>()
{
private Dictionary<int, List<T>> dictionary { get; set; }
public MyWrapper() { dictionary = new Dictionary<int, List<T>>(); }
// Adds a new item to the collection
public void Add(int key, T item)
{
List<T> list = null;
if (!dictionary.TryGetValue(key, out list))
{
// If dictionary does not contain the key, we need to create a new list
list = new List<T>();
dictionary.Add(key, list);
}
list.Add(item);
}
public IEnumerable<T> this[int key]
{
get
{
List<T> list = null;
// We just return an empty list if the key is not found
if (!dictionary.TryGetValue(key, out list)) return new List<T>();
else return list;
}
}
}
Obviously, your needs might be different, you might need to implement a couple of interfaces, etc., but this is the general idea.