المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Refactoring question



C# Programming
08-26-2009, 04:52 AM
Hi

I have a Windows Forms Application and I have written a piece of code that makes sure that there will always only be one instance of a form open in my MDI app.

My code looks like this:

private static Forms.Employees.EmployeeForm _newEmployeeForm;

public static Forms.Employees.EmployeeForm GetChildInstance()
{
if(_newEmployeeForm == null || _newEmployeeForm.IsDisposed)
{
_newEmployeeForm = new EmployeeForm();
}
return _newEmployeeForm
}

My question is this, How can I make this code generic so that all my forms can inherit this functionality?

Thanks!

Illegal Operation