Mono.Addins 0.4.0.0 1.0.0.0 System.Object A condition evaluator. Add-ins may use conditions to register nodes in an extension point which are only visible under some contexts.

For example, an add-in registering a custom menu option to the main menu of a sample text editor might want to make that option visible only for some kind of files. To allow add-ins to do this kind of check, the host application needs to define a new condition. Conditions are defined like this:

`<Addin namespace="TextEditor" id="Core" version="1.0"> ... <ConditionType id="Openfile" type="TextEditor.OpenFileCondition" /> ... </Addin>`

This condition defined in the add-in host can be referenced by add-ins like this:

`<Addin namespace="TextEditor" id="Xml"> ... <Extension path = "/TextEditor/MainMenu/Edit"> <Condition id="OpenFile" extension="xml,config"> <MenuSeparator insertafter="Paste" /> <MenuItem label="Format XML" commandType="TextEditor.Xml.FormatXmlCommand" /> </Condition> </Extension> ... </Addin>`

Meaning that a separator and new "Format XML" command will be added after the "Paste" command, but only if the current open file has the extension ".xml" or ".config".

Extension points are dynamically updated when the status of a condition changes. Nodes matching the new condition status will be added, and nodes which do not match the condition will be removed.

Conditions are implemented using a subclass of . For example, OpenFileCondition might be implemented like this:

`namespace TextEditor { public class OpenFileCondition: ConditionType { public OpenFileCondition () { // It's important to notify changes in the status of a condition, // to make sure the extension points are properly updated. TextEditorApp.OpenFileChanged += delegate { // The NotifyChanged method must be called when the status // of a condition changes. NotifyChanged (); }; } public override bool Evaluate (NodeElement conditionNode) { // Get the required extension value from an attribute, // and check againts the extension of the currently open document string val = conditionNode.GetAttribute ("extension"); if (val.Length > 0) { string ext = Path.GetExtension (TextEditorApp.OpenFileName); foreach (string requiredExtension in val.Split (',')) if (ext == "." + requiredExtension) return true; } return false; } } }`

The add-in engine will create an instance of OpenFileCondition when needed, and will call Evaluate to get the result for a specific condition node.

- Constructor
  Creates a new instance.
  0.4.0.0
- Method
  System.Boolean `` Condition node information. Evaluates the condition. 'true' if the condition is satisfied. This method must be overriden to evaluate the condition for the provided node, and should return 'true' if the condition is satisfied. 0.4.0.0
- Method
  System.Void Notifies that the condition has changed, and that it has to be re-evaluated. This method must be called when there is a change in the state that determines the result of the evaluation. When this method is called, all node conditions depending on it are reevaluated and the corresponding events for adding or removing extension nodes are fired. 0.4.0.0