R
Rader
Hello everybody,
I have a method "CreateInstance" defined in the following code snippet:
//To create an instance by a class's full name,but shoult check if it
can be multi-instantiated at first
public T CreateInstance<T>(string classFullName, bool
canMultiInstantiated)
{
T instanceName;
if (!canMultiInstantiated)
{
//check if the class has been instantiated
//yes: continue
//no: instanceName=TheExistingInstance
//and return the reference of the existing instance
bool existing = CheckForExistance(classFullName);//dont
know how to check
if (existing)
return TheExistingInstance; // I do want to return
the ref of the existing instacne ,but dont know how
// return default(T);
}
instanceName =
(T)Activator.CreateInstance(Type.GetType(classFullName, true, false));
return instanceName;
}
I have create an instance by the class full name successfully, but I
dont know how to check if another instance has been existing in the
current applicaiton ,can anyone help me??
Thanks very muck!
I have a method "CreateInstance" defined in the following code snippet:
//To create an instance by a class's full name,but shoult check if it
can be multi-instantiated at first
public T CreateInstance<T>(string classFullName, bool
canMultiInstantiated)
{
T instanceName;
if (!canMultiInstantiated)
{
//check if the class has been instantiated
//yes: continue
//no: instanceName=TheExistingInstance
//and return the reference of the existing instance
bool existing = CheckForExistance(classFullName);//dont
know how to check
if (existing)
return TheExistingInstance; // I do want to return
the ref of the existing instacne ,but dont know how
// return default(T);
}
instanceName =
(T)Activator.CreateInstance(Type.GetType(classFullName, true, false));
return instanceName;
}
I have create an instance by the class full name successfully, but I
dont know how to check if another instance has been existing in the
current applicaiton ,can anyone help me??
Thanks very muck!