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?
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"
}]
}
Related
I'm trying to work on an environment that its main function is to adopt Visual Programming to create NetLogo code (similar to Google's Blockly).
Right now, I'm using Unity3D to do the job and wondering if it's possible to access NetLogo from it. The objective is to send the generated code directly into the Code Tab, opening a blank project already with the code in the tab (without the user copying and pasting it there).
What I know up until now is that I can open NetLogo from Unity with a function called Process.Start, which takes 2 arguments: the first is the name of the target program to be executed ("NetLogo.exe"), the second one is a list of arguments that can be passed to the targeted program, which solely depends on each program, as found here and here. However, I didn't understand much about these arguments, which is why I recurred to ask.
Do I need to also work on a Java/Scala environment to do this for me with the Extensions API, or can I use these arguments in Process.Start to do it?
Thanks in advance.
You could create a fully formed .nlogo file (it's basically a text file with a specific format), and then launch NetLogo using your Process.start command with that filename as an argument so that NetLogo will open that specific file.
You could even create a .nlogo file as a template (with whatever interface items you want), and then use string search/replace to substitute in the code that you want in the code tab.
Alternatively, fancier things are possible with the Controlling API , but I don't know much about calling JVM code from within Unity, and I suspect that will be a bigger headache than you want... unless you really need a more tight-knit connection to NetLogo, or unless the performance overhead of starting a new NetLogo process each time is unacceptable.
Experienced .NET developer here (but only client object experience in SharePoint). Here's my scenario:
In SharePoint 2013 a user checks in an existing/new file after making changes
File check code (c# pref) is run against the file being checked in
If file passes checks continue check in
If file fails, discard check in, inform the user that the check in has failed & provide the reasons why it failed (reasons supplied by file check code).
I already have the file checks implemented as a c# class lib (used in a couple of other apps). I would like to be able to limit this to a specific folder (and all child folders within) and file type (identified by file extension).
What's the best practices method of implementing this? My guess is to tie into existing SP events to determine check in and insert my file check class into that execution path. In a perfect world I'd find a tutorial demonstrating this. :)
Thank you in advance for your time.
Regards,
Falconeer
what you want is to develop a SharePoint farm solution which uses the event receivers. There are specific event receivers which will fire when someone checks in a document. Then you should do your logic there.
http://beginnersbook.com/2013/02/event-receivers-in-sharepoint/
Watch out for the event receivers - checkingin - checkedin. There is a difference between the two. The one is synchronous, the other asynchronous. I would put your logic in the -ing event receiver as this allows you to cancel the checkin.
You might have to play with before and afterproperties to do the appropriate check on folder, file, etc...
http://www.sharepointalex.co.uk/index.php/2010/06/beforepropertiesafterproperties-in-event-receivers-i-always-forget-this/
This should be the way to go!
I would like a particular type of file (eg. Namefile.ext2) read all the names preceded by a #
Sample contents of the file:
#nameone
#nametwo
#namethree
When I click the right mouse button on the ext2 file extension beyond the standard options (like: open, properties, etc ...) I would like to be:
contents of the file > nameone
nametwo
namethree
Then, select the item (eg. nameone) pass this parameter to my program running in the background / or services
Do you need to modify the registry somehow? I will be grateful for tips on how to achieve the desired effect.
What you are asking about is called 'shell extension'. Basically it requires some knowledge of COM objects programming, but .NET made things a bit easier in that matter.
Shortly: you have to develop a piece of code which will reads the file and generates menu items dynamically (which may be tricky but possible). That code needs to be registered in the system as COM object.
Before it starts working you have to associate file extension with COM object you created.
Perhaps this article can explaint it a bit more:
http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus
I have a C# solution which contains a project and a class library written by somebody else. The class library gets GPS data via wifi. The project shows the processed data on a map. Now, I want to see the contents of some variables in the class library in real time for the sake of debugging.
I tried to use
System.Diagnostics.Debug.Write(value)
without success. It seems it does not do anything.
Also I tried "MessageBox.Show(value.ToString())" which was good but it stopped the wifi reading and interrupted the program as I needed to press OK button each time that it showed up.
Moreover, I added a windows form (which contained a textBox) to the class library to print the data in the textBox, however, when I wrote:
Form1.textBox1.Text = value.ToString()
It gives me this error:
Error 3 'MapNMEA.Form1.textBox1' is inaccessible due to its protection level C:\Users\john\Documents\Visual Studio 2010\Projects\new ver of map purecom\MapExplorer\MapExplorer\MapNMEA\MapNMEA\SerialPort.cs 184 27 MapNMEA
"MapNMEA" is the name of the class library. Also "MapExplorer" is the name of both solution and the project. "SerialPort.cs" is a file inside the class library in which I wrote the above code.
My question is how to show the content of those variable (they are 3,4 variables) in real time and this act should not stop the wifi reading. I need to do this as an electrician who does not know much about programming wants to check whether a GPS device sends the data to my computer correctly or not.
UPDATE 1: Actually I noticed that System.Diagnostics.Debug.Write(value) is working but as there was too many warning messages showing up in the debug window, I did not noticed it. Now, if somehow I could remove (or hide) other (warning) messages, I would see only my desired output. Do you know?
Debug.Write should be fine if you attach a listener first (Debug.Listeners.Add( new _a_listener_type() )).
Also, you should probably be aware of the AutoFlush property on the Debug class which determines whether or not Flush is automatically called.
Debug.Write should work - by default it will write to the 'Debug' window in Visual Studio if you have the debugger attached. Are you sure you're looking in the right place?
If you want to use the form approach, you need to keep track of the instance of the form which is open, and give it a public method. For example:
public void WriteDebug(string message) {
TextBox1.Text += message + Environment.NewLine;
}
Then you can call formInstance.WriteDebug(message);.
Do you run debug build? Also your code with textbox does not work, because textBox1 is non-public
I think you may not be searching the right location: Is there something preventing you from debugging on a PC first before going to a target? If not, the you should probably use the traditional way: put spies on variables, use your IDE (Visual Studio) to watch them and so on.
If you actually NEED to run on target without advanced debug tools, then you might want to take a look at some easier solutions:
log them to a text file (append or replace, whatever you need), then have a viewer opened at hand
make another non-modal form with a textbox, and call a form2.writeDbgTextBox(String) every time you need to refresh
Be sure to remove this code on release (eg. by putting them in a #if DEBUG section)
And whatever happens, DO NOT try to write to an existing Message box! they are made to pop up and close, not to interact with your code.
I'm new to SharpSVN (and frankly--pretty new to C# as well). I've been trying get a simple pre-commit hook working which checks for a comment. (i.e. the commit fails in the absence of a comment)
There are several posts (like this one) which are related and helpful, but I have a few fundamental questions that are keeping me from getting further:
1) How do I get code like the link above running in C#? (i.e. which C# context would I use-- console application? csharp class?)
2) In a Windows Server context, how do I call my compiled C# program?
I've tried this answer's methodology with no luck.
Thanks in advance.
If you are creating a pre-commit hook you should call it pre-commit.exe. (Subversion accepts hook with the extensions .exe, .cmd, .bat and .wsf.)
Hooks communicate via stdout, stderr and in some cases stdin, so you should compile your application as a console application.
To get the hook working you must place the .exe (and the required DLLs) in the hooks directory of the repository.
See How to access file information in a pre-commit hook using SharpSVN for some examplecode.
Compile your "hook" as a console application, and then write a batch file that calls your console application. The batch file needs to be named correctly and placed in the "hooks" folder of your Subversion repository.
For your specific case, the batch file should be called pre-commit.bat (or pre-commit.cmd).
I had to keep users from commiting to the wrong branch by mistake. So I wrote a pre-commit hook that would check the comment for a key value. If the comment doesn't start with the right key the commit is aborted.
Here is the project:
http://sourceforge.net/projects/csvnprecommit/
Feel free to use it as a base for your own hook or use it as is. If you find a bug submit it to the project.