Note that there are some explanatory texts on larger screens.

plurals
  1. POC# plugin architecture question
    primarykey
    data
    text
    <p>I'm working on a system monitoring application similar to Nagios in C#. I have a plugin interface defined as:</p> <pre><code>public interface IPlugin { PluginResult Execute(); } </code></pre> <p>Each plugin, depending on its functionality, will have a variable number of arguments. As an example, a ping plugin might take a hostname, # of packets, timeout value, etc. I want the user to be able to define these arguments per service in my user interface, but obviously these arguments won't be known until the application discovers which plugins are available. I'm curious as to how others might design a plugin such that these variable arguments would be discoverable by the application.</p> <p>Right now, as an example, I've got a ping plugin:</p> <pre><code>public class PingPlugin : IPlugin { private const string RESULT_MESSAGE = "Average ms: {0}; Packet loss: {1}"; private string _hostname; private int _packets; private int _timeout; private int _warningTimeThreshold; private int _warningLossThreshold; private int _errorTimeThreshold; private int _errorLossThreshold; public PingPlugin( string hostname, int packets, int timeout, int warningTimeThreshold, int warningLossThreshold, int errorTimeThreshold, int errorLossThreshold) { _hostname = hostname; _packets = packets; _timeout = timeout; _warningTimeThreshold = warningTimeThreshold; _warningLossThreshold = warningLossThreshold; _errorTimeThreshold = errorTimeThreshold; _errorLossThreshold = errorLossThreshold; } public PluginResult Execute() { // execute the plugin } } </code></pre> <p>I thought I might be able to discover the constructor parameters using reflection and present the user with a property grid to allow the configuration of the plugin, but I'm not sure the best way to provide a set of default values with this design. What might some alternatives be?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload