Workflow and ServiceDesk Community

 View Only

Workflow - Component - Developer Guide - Inputs - DropDown 

Nov 09, 2016 05:42 PM

In this Article I'm going to explain how to add a Input of a Dropdown / Combo to gather more configuration from the User.

- - -

When using the Pad Text component I noticed it used a DropDown to allow a choice of options. This could be useful in a Component I was creating so I thought I'd investigate how this was configured.

transform.pngPad Text
Class: LogicBase.Components.Default.Process.PadText
Library: LogicBase.Components.Default.dll

Components - PadText - Configuration.png

If you've completed the Inspecting article you will already have this DLL ready, re-open it in your Decompiler of choice.

Find 'PadText' under 'Process'.

We need to find the PadType configuration.

First the Declaration

private PadText.PadTypeEnum _padType;

This is new, it's using an Enum. This is a much better way then an Array of Strings.

public enum PadTypeEnum
{
    Left,
    Right
}

ReadFromStream

public override void ReadFromStream(ObjectReadStream info)
{
    ...
    this._padType = (PadText.PadTypeEnum)info.GetValue("padType", typeof(PadText.PadTypeEnum));
    ...
}

WriteToStream

public override void WriteToStream(ObjectWriteStream info)
{
    ...
    info.AddValue("padType", this._padType);
    ...
}

Run

public override void Run(IData data)
{
    ...
    char value = (char)this._padChar.GetValue(data);
    switch (this._padType)
    {
        case PadText.PadTypeEnum.Left:
        {
            str1 = str1.PadLeft(this._padLength, value);
            break;
        }
        case PadText.PadTypeEnum.Right:
        {
            str1 = str1.PadRight(this._padLength, value);
            break;
        }
    }
    ...
}

A switch statement is used to consider each choice made.

If we want to use a drop down in our own components we can create our own Enum and use that instead.

Protirus.png

Statistics
0 Favorited
1 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Related Entries and Links

No Related Resource entered.