Chronos Plugins 5.9.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockPlugin.SampleList.RemotePluginService Class Reference

Example for communication with external programs. More...

+ Inheritance diagram for MockPlugin.SampleList.RemotePluginService:
+ Collaboration diagram for MockPlugin.SampleList.RemotePluginService:

Public Member Functions

bool DoSomething (string someParameter)
 Just uses a messagebox to show the external request.
 
- Public Member Functions inherited from MockPlugin.RemoteAccessTester.IMockPlugin

Static Public Member Functions

static void StopService ()
 

Static Private Member Functions

static void HostFaultedHandler (object sender, EventArgs e)
 

Private Attributes

System.Windows.Forms.Form mMainWindow
 

Static Private Attributes

static ServiceHost mHost
 

Detailed Description

Example for communication with external programs.

This example uses WCF to show how you can trigger actions within the plugin from external programs. See RemoteAccessTester.MessageTesterForm for the client side. Please note that WCF will be discontinued by Microsoft, the server components will not be part of .Net Core in the future. So, while this is a working example for current Chronos releases, you should maybe not base a new project on this method of interprocess communication, but switch to something else like gRPC or an ASP.net WebAPI.

Definition at line 19 of file RemoteServiceImplementation.cs.

Member Function Documentation

◆ DoSomething()

bool MockPlugin.SampleList.RemotePluginService.DoSomething ( string someParameter)

Just uses a messagebox to show the external request.

Parameters
someParameter
Returns

Implements MockPlugin.RemoteAccessTester.IMockPlugin.

Definition at line 27 of file RemoteServiceImplementation.cs.

28 {
29 if (mMainWindow == null)
30 {
31 mMainWindow = System.Windows.Forms.Control.FromHandle(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle) as System.Windows.Forms.Form;
32 }
33 // Just a few manipulations of the main window
34 if (mMainWindow != null)
35 {
36 someParameter = someParameter.ToLowerInvariant();
37 switch(someParameter)
38 {
39 case "hide":
40 mMainWindow.Hide();
41 break;
42 case "show":
43 mMainWindow.Show();
44 break;
45 case "min":
46 mMainWindow.WindowState = System.Windows.Forms.FormWindowState.Minimized;
47 break;
48 case "max":
49 mMainWindow.WindowState = System.Windows.Forms.FormWindowState.Maximized;
50 break;
51 }
52 }
53 else
54 {
55 System.Windows.Forms.MessageBox.Show("Could not get main window");
56 }
57 return System.Windows.Forms.MessageBox.Show(
58 $"Plugin does something on remote request: {someParameter}\nSucceeded?",
59 "Remote request to plugin",
60 System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes;
61 }

References MockPlugin.SampleList.RemotePluginService.mMainWindow.

◆ HostFaultedHandler()

static void MockPlugin.SampleList.RemotePluginService.HostFaultedHandler ( object sender,
EventArgs e )
staticprivate

Definition at line 63 of file RemoteServiceImplementation.cs.

64 {
65 System.Diagnostics.Trace.WriteLine("Remote plugin service failed.");
66 }

◆ StopService()

static void MockPlugin.SampleList.RemotePluginService.StopService ( )
static

Definition at line 78 of file RemoteServiceImplementation.cs.

79 {
80 try
81 {
82 if (mHost?.State == CommunicationState.Opened)
83 {
84 mHost?.Close();
85 }
86 }
87 catch
88 {
89 // nothing
90 }
91 }

References MockPlugin.SampleList.RemotePluginService.mHost.

Referenced by MockPlugin.SampleList.MockSampleListWorker.Dispose().

Member Data Documentation

◆ mHost

ServiceHost MockPlugin.SampleList.RemotePluginService.mHost
staticprivate

◆ mMainWindow

System.Windows.Forms.Form MockPlugin.SampleList.RemotePluginService.mMainWindow
private

The documentation for this class was generated from the following file: