What should I need to automate a tool which is in C#.net
I have a tool created in C#.net and want to automate that tool in ruby, currently this tool is alpha phase, should I create COM file in C# or should I create keyboard shortcut to automate that 开发者_StackOverflowtool in Ruby? which one is the best way?
Im not sure what you mean by creating keyboard shortcuts, perhaps as a crude message passing system?
Anyhow, I beleive the typical method to allow external control/scripting is to expose an API for your program. On the occasions I have needed to do something similar myself, I usually create an interface containing all the publicly exposed methods and then have my main application class implement this interface. You will probably need to make this COM visible to allow non .NET environments to access the interface, yes. Although IIRC this is quite simply just a build option, atleast in VS 2010 it is a simple option in the project properties.
Of course, depending on how complicated your tool is, or exactly the data and functions you wish to expose, you may need to provide multiple public interfaces which can be accessed from a script, but ofgten only 1 is sufficient. One advantage of using interfaces is in this case, you can still possibly implement it within a single class.
In addition to Aaron's response: your API should be accessible to non-.NET applications, meaning you should use some kind of standard interface, such as a TCP socket, or some kind of message queue, named pipes (if such thing exists on Windows) etc.
If I was on the other side, writing Ruby automation app (which I often actually am), I would vote for a network socket utilizing some simple protocol, REST or a subset of it, with XML or (even better) JSON as a data carrier.
As for implementing these, I would be surprised if there isn't some kind of small .NET HTTP server that you can easily embed into your application.
精彩评论