We are creating a simple but improved billing solution. Since we have to use different providers based on a number of reasons that is of no importance right now I was thinking of what would be the best way to handle this. The different providers might have a key and a value. I can store the value as object but then I need to store the type as well. I was thinking of creating a hmm let’s call it Tuple class:
public class Tuple<TType, TValue>
{
public TType Type { get; set; }
public TValue Value { get; set; }
}
Now I can use this for storing the type reference but it I have a feeling something is missing. To use this with a lookup collection like dictionary I could:
public IDictionary<string, Tuple<Type, object>> TechnicalDetails =
new Dictionary<string, Tuple<Type, object>>
Suggestions for improvement? There has got to be a better way? 🙂
In cases like this, I tend to write a class to contain/hide the data structure, and to provide methods and properties which abstract away the details of the data structure, in this case, your
Dictionary<string, Tuple<Type, object>>.Methods like Find( ), Get( ), Add( ), Remove( ) etc, are easy to add since the data structure itself already has similar methods.