Transformers – MetroTextual Plugins

Transformers are simple plugins that transform the current text selection. They can provide a wide variety of functions, such as encoding/decoding, encryption/decryption or translation.

transformers

Available Transformers

Base64 Encoding/Decoding Encodes or decodes the selected text with Base64
To Lower/Upper case Converts the selected text to either upper or lower case
Create HTML List Adds <li></li> tags around multiline text selection

Installing Transformers

Transformers need to be installed in C:\Program Files\MetroTextual\plugins\transformers. Simply extract the downloaded zip and place the provided .DLL file into ‘plugins\transformers,’ relative to MetroTextual’s install location. They will automatically be detected and loaded by MetroTextual.

Creating Custom Transformers

Transformers are incredibly simple to write. They are created as .NET Class Libraries (.DLL files), which can be written in any .NET language (such as VB.NET or C#).

Below is the entire source code for the “Convert to Base64” transformer. In a nutshell, MetroTextual passes the selected text to the Transform method in the Base64 class, which return a string containing the new text.

[code language=”csharp”]
using System;

namespace Base64
{
public class Base64
{
public string Transform(string original_text)
{
//Convert to base64
string returnValue;
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(original_text);
returnValue = (Convert.ToBase64String(bytes));
return returnValue;

}
}
}
[/code]

Points of interest:

  • The assembly name must be identical to the class name.
  • public string Transform(string original_text) {” must be used as the method signature
  • In VB.NET, use “Public Function Transform(ByVal original_string As String) As String
  • You do not need to handle exceptions. MetroTextual handles this internally

The transformer description shown in MetroTextual is determined by the contents of the ‘description’ field in the assembly information.
AssemblyInformation

 Leave a reply