One of the most promising perspectives in scriptcs, in my opinion, is hosting. Basically hosting is the complete package of scriptcs, just put inside your own application. It can be pretty mind blowing to think about this. Hosting makes it possible execute C# scripts inside of any standard .Net application.
With my scriptcs.rebus project, I wanted to add a feature, which would use scriptcs.hosting for executing scripts inside of a host. The script was supposed to be send over either MSMQ, RabbitMQ, or Azure Service Bus. When the host received the script it would be executed. It should also be possible to added NuGet references, local dependencies, and import namespaces to be used by the script.
I had read the excellent blog post by Filip Wojcieszyn on extending Glimpse using scriptcs. This blog post gives a small hint on the perspectives for scriptcs hosting. When I came up the idea of combining scriptcs hosting with messaging, I had a Jabbr session with Glenn Block, who guided me in the right direction.
The end of the session with Glenn, was that all I needed to do was reference scriptcs.hosting
, and I should be given all the dependencies needed.
Initial Attempt
I started looking into how the internals of scriptcs is working, and how hosting in particular is working. I soon realized that there is a number of different dependencies at work, and quickly came up with idea of using AutoFac, which is also used inside of scriptcs hosting. I wrote a rather nice script module, on which I registered all my dependencies from scriptcs.hosting
.
This script module would be registered in my ScriptHandler
. The ScriptHandler subscribes to messages of type Script
: