Optimization : Optimization.Dispatcher Namespace

Dispatcher Class

Dispatcher class.

public abstract class Dispatcher

Remarks

The dispatcher class can be used to implement dispatcher applications that evaluate a specific task.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Members

See Also: Inherited members from object.

Public Constructors

Create new dispatcher.

Public Properties

[read-only]
default property
Item (string) string . Get a setting by name.
[read-only]
Parameters List<Parameter> . List of parameters.
[read-only]
RequestAvailable bool . Get whether a request is available.
[read-only]
Settings Dictionary<string, string> . Dispatcher settings.
[read-only]
Task Optimization.Messages.Task . The task.

Public Methods

ContainsParameter (string) : bool
Get whether a certain parameter is available.
ContainsSetting (string) : bool
Get whether a certain setting is available.
ParameterByName (string) : Parameter
Get a parameter by name.
Run () : bool
Run the dispatcher.
Setting<T> (string) : T
Convenient method to get the value of a setting and automatically convert it to a certain type.

Protected Methods

RequestStream () : System.IO.Stream
Get the stream from which to read the request.
abstract
RunTask () : bool
Run the task.
WriteResponse (Optimization.Messages.Response) : bool
Write a response to the worker.

Public Operators

static
Conversion to System.Boolean (Implicit) Implicit conversion to bool.

Member Details

Dispatcher Constructor

Create new dispatcher.

public Dispatcher ()

Remarks

Create new dispatcher.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

ContainsParameter Method

Get whether a certain parameter is available.

public bool ContainsParameter (string name)

Parameters

name
The parameter name.

Returns

Wether a certain parameter is available.

Remarks

Use this method to check if a certain parameter is available.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

ContainsSetting Method

Get whether a certain setting is available.

public bool ContainsSetting (string str)

Parameters

str
The setting name.

Returns

Whether a certain setting is available.

Remarks

Use this method to check if a certain setting is available.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Item Property

Get a setting by name.

This is the default property for this class.

public string this [string key] { get; }

Parameters

key
The setting name.

Value

The setting value.

Remarks

Get a setting by name. This will return null if the setting is not found.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Conversion Method

Implicit conversion to bool.

public static implicit operator bool (Dispatcher dispatcher)

Parameters

dispatcher
The dispatcher object.

Returns

True if the dispatcher has received the task request.

Remarks

Use this method to check if a task request has been received.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

ParameterByName Method

Get a parameter by name.

public Optimization.Parameter ParameterByName (string name)

Parameters

name
The parameter name.

Returns

The parameter, or null if parameter could not be found.

Remarks

Get a parameter by name.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Parameters Property

List of parameters.

public List<Optimization.Parameter> Parameters { get; }

Value

List of parameters.

Remarks

Get a list of all the parameters.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

RequestAvailable Property

Get whether a request is available.

public bool RequestAvailable { get; }

Value

True if a request is available, false otherwise.

Remarks

Check whether a request has been received.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

RequestStream Method

Get the stream from which to read the request.

protected virtual System.IO.Stream RequestStream ()

Returns

The stream from which to read the request.

Remarks

By default, this will return a stream to the standard input of the process. Subclasses can override this to get the request data from somewhere else.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Run Method

Run the dispatcher.

public virtual bool Run ()

Returns

True if the dispatcher finished evaluating the task successfully, false otherwise.

Remarks

Run the dispatcher. This will first read the request and when successfully read, run Dipatcher.RunTask. Implementations should usually only need to implement Dipatcher.RunTask.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

RunTask Method

Run the task.

protected abstract bool RunTask ()

Returns

True if the task was evaluated successfully.

Remarks

Implementations must implement this method which does the actual task evaluation.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Setting<T> Generic Method

Convenient method to get the value of a setting and automatically convert it to a certain type.

public T Setting<T> (string name)

Type Parameters

T
Setting value type.

Parameters

name
Setting name.

Returns

The setting value.

Remarks

Use this to easily convert settings to a specific type. Settings are transmitted as strings, but often you have settings that contain double values for example.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Settings Property

Dispatcher settings.

public Dictionary<string, string> Settings { get; }

Value

Dispatcher settings.

Remarks

The dispatcher settings. These settings will be send along with the task request to the dispatcher process.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

Task Property

The task.

public Optimization.Messages.Task Task { get; }

Value

The task.

Remarks

Get the task to be dispatched.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)

WriteResponse Method

Write a response to the worker.

protected bool WriteResponse (Optimization.Messages.Response response)

Parameters

response
The response to write.

Returns

True if the response was written successfully.

Remarks

Use this method to write a response back to the worker after you have evaluated a task.

Requirements

Namespace: Optimization.Dispatcher
Assembly: Optimization (in Optimization.dll)