I am thinking of something in the "Inline Task" build in MsBuild. For reference: http://msdn.microsoft.com/en-us/library/dd722601.aspx
I would like to find or create a framework that allows me to override a method through configuration. For example, if I have a well-known base class that has an Execute (args) method, how can I ensure that an overridden method is implemented during deployment without requiring a new code loop, build, release? I would like to actually connect the body of the method to the configuration file, or preferably to the database table.
I assume that this will be done either with dom code, or with dynamic language integration, or perhaps with something like powershell (?). I am looking for recommendations, or perhaps a library that someone has already written.
The application is written in C #. Preferably the extension will also be in C #, but I'm also open to other ideas.
Update: Technically, I donβt even need to redefine the method. It is enough just to be able to dynamically execute some external source code, pass to arg and return the result.
Update I ended up writing code to instantiate a PowerShell object and dynamically execute the script to return the value. Here is the code snippet I used.
public static Collection<PSObject> ExecuteScript(string code, string variableName, object variableValue) { PowerShell ps = PowerShell.Create(); ps.AddScript(code); if (!string.IsNullOrWhiteSpace(variableName)) { ps.Runspace.SessionStateProxy.SetVariable(variableName, variableValue); } var result = ps.Invoke(); return result; }
Then in the calling code, I simply check the first PSObject in the return value and pull the resulting value out of it. It works great. Thanks for all the answers.
source share