Skip to content

Instantly share code, notes, and snippets.

@iguigova
Created May 16, 2012 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iguigova/2714340 to your computer and use it in GitHub Desktop.
Save iguigova/2714340 to your computer and use it in GitHub Desktop.
Activator.CreateInstance example
public static ICommand GetCommand(HttpRequest httpRequest)
{
try
{
return ((ICommand)Activator.CreateInstance(Type.GetType(string.Format("{0}.Cmd{1}", MethodBase.GetCurrentMethod().DeclaringType.Namespace, httpRequest.Headers["Command"])))).Init(httpRequest);
}
catch (Exception ex)
{
return new Command(ex);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment