Last post Jun 24, 2010 09:48 AM by toas1
Jun 24, 2010 03:30 AM|Coool|LINK
I know this forums is for web application related issues but my question is more related to framework.
In my desktop application, I have created Singleton form provider with the use of generic.
For an example I have 4 forms AddEmployee, EditEmployee, AddOrder, EditOrder. Now, I want to add function to delete objects of all forms (maintained in lookup dictionary of Singleton class) except the list of type provided in the function.
I tried using the following method that failed in compilation.
public static void RemoveAllExcept<T>(params Type<T> list)
where T : Form
// check in lookup dictictionary and delete if not in Type<T> list
and to use function I want to use something like
How to achieve this functionality?
Jun 24, 2010 07:52 AM|toas1|LINK
I think you make this more complicated then it has to be.
I dont see why you need to use generics here but on the other hand I dont see the big picture either. The thing is that you cant do "Type<T>". But cant you just make it without generics? Something like this?
public static void RemoveAllExcept(params Type list)
// check in lookup dictictionary and delete if not in type is in list
Jun 24, 2010 09:11 AM|Coool|LINK
I have already made that function. However, I am thinking to make it more type safe by providing type of passed list of T.
For an example the function you mentioned can pass type of any class. However I only want to pass type of those class classes that is inherited from class "Form".
Is it possible?
Jun 24, 2010 09:48 AM|toas1|LINK
I understand the reason but I think the only way to make it is to send in a array of actual instances of T and not the types.