Search code examples
c#pluginsterminologyextensiblesbt-crossproject

Finding some terminologies for doing R&D


I am here because I have a program and some features in my mind.

But I am not sure what these features are called in programming terms. So I am unable to even do a proper google search regarding the same. I am keen to identify what this is called, so I can progress my Analysis and Research.

I have developed a program, with C# and Windows Forms. Currently it interfaces with YouTube API and monitors the chat. I am also raising some events, when chat messages arrive and when the message follows a certain format/syntax. Everything is working fine so far.

What I want to do is:

If someone using my software, who has access to just the binaries. But want to write their own logic, which handles some of the events I am raising. How do they do that?

I want the user to write their own program/class, put it in a specific folder. I will expect it to have a Start() and End() method. Inside the methods, they can write the code to subscribe to any event of their choice and do what they need to.

I already have written code inside my main loop, which will loop through the folder which is supposed to contain the user programs, and tries to invoke the Start/End method of their programs/classes.

For me, as the original author of the project, I can just go ahead and start writing the code inside the folder. Once I build and execute. Everything works fine. The main program triggers the Start/End inside the program/class that I added. And the events are also handled fine.

But how about someone using my software, who wants to handle it's events, without having to re-compile my code. How do they do that?


Solution

  • You have the following options
    Option 1

    • Create a template project with all required references and a code file (.cs) with the Start() / End() methods.
    • Add comments to the start() / end() methods or add a code sample of how they can work with the additional events.
    • The project should compile fine without any source code for your main project.
    • If you expect the users to use Visual Studio Code, give them instructions to compile using VS code.
    • If they are going to use any text editor, you need to provide them with a msbuild command line to compile their code.
    • Finally they can put the .cs code file in the specific folder along with your main project binary and try it out.

    Option 2

    • The above option will work only if your users are also programmers.
    • If they are semi-techies, you could provide a simpler format for them to provide the additional events.
    • For example, create a json or xml format where they can specify the event name and how they want to handle it - either a script or choose from some options. For example -
        {
          "myevents": [
          {
            "event": "chatUpvote",
            "handler": "ThankYouHandler"
          },
         {
           "event": "chatDownvote",
           "handler": "TellMeMoreHandler"
          }]
        }