Opinion needed
I want to write a resbuf wrapper class for my little Intellicad project.
If you were writing one using .Net 2.0 generics would you use a similar TypedValue structure
or use one of the built-in generic dictionaries I.e
static Dictionary<int, Object^> ^ToDictionary(resbuf * inl_List)
{
Dictionary<int, Object^> ^mDict = gcnew Dictionary<int, Object^>();
//
for (resbuf * lList=inl_List; lList; lList=lList->rbnext)
{
switch ( lList->restype )
{
case RTSTR:
mDict->Add(lList->restype , safe_cast<Object^>(gcnew String(lList->resval.rstring)));
break;
case RTSHORT :
mDict->Add(lList->restype , safe_cast<Object^>(lList->resval.rint));
break;
case RTLONG :
mDict->Add(lList->restype , safe_cast<Object^>(lList->resval.rlong));
break;
case RTREAL :
mDict->Add(lList->restype , safe_cast<Object^>(lList->resval.rreal));
break;
//todo add the rest of the types
}
}
return mDict;
}
//
static List<KeyValuePair<int, Object^>> ^ToList(resbuf * inl_List)
{
List<KeyValuePair<int, Object^>> ^mList = //
gcnew List<KeyValuePair<int, Object^>>(ToDictionary(inl_List));
return mList;
}
Thanks