This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* You will need "using System.Reflection;" | |
* This method allows you to dynamically load a specific factory that inherits from a base factory. | |
* The variable "factoryAssembly" is a string that represents the path to the factory DLL. | |
* The variable "factoryClass" is a string that represents class to be instantiated. | |
*/ | |
public BaseFactory GetFactory(string factoryAssembly, string factoryClass) | |
{ | |
Assembly assembly = Assembly.LoadFile(factoryAssembly); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* You will need "using System.Reflection;" | |
* The variable "method" is a string that represents the case-sensitive name of the method to be called. | |
* The variable "context" in this instance is the HttpContext, but can be any variable(s) the method expects. | |
* In this example the called method returns a string, so the invocation is cast into a string, but this can change based on what the method returns. | |
*/ | |
Type _t = this.GetType(); | |
MethodInfo _methodInfo = _t.GetMethod(method); | |
string result = (String)_methodInfo.Invoke(this, new object[] { context }); |
NewerOlder