vendredi 26 octobre 2018

Calling a script by name

I was thinking if there is any way of calling a script only using its name(so a string) and casting it into an interface implemented by it. I know of the Activator way, which looks like this:

protected static I CreateInstance<I>(string myClassName) where I : class
{
    var createdInstance = Activator.CreateInstance(null, myClassName);
    return createdInstance.Unwrap() as I;
}

But is there any other way? Thanks!





Aucun commentaire:

Enregistrer un commentaire