Getting Started Creating Custom Search Option

First steps

First you want to derive your new class from ISearchHeader as in the code example below.

CopyC#
public class StringNotEqualSearch : ISearchHeader
 {
     public string Label
     {
         get { throw new NotImplementedException(); }
     }

     public SearchDisplayInfo DisplayInfo
     {
         get { throw new NotImplementedException(); }
     }

     public bool Search(object value, string searchValue)
     {
         throw new NotImplementedException();
     }
 }

These are the functions that must be defined for it to compile and be a fully functional Settings Action

API Reference

  • Label: This is the friendly name that is displayed ot the user.

  • DisplayInfo: This Displays information about the search itself

    Note

    SearchDisplayInfo holds information about the search itself. It takes max three paramaters:

    • Type: This is the DisplayType of the search. This is what kind of values this search can act upon. You can specify Boolean (true/false), string, integer, Date, Collection (a Set of objects), and None.

    • SearchType:This is the type of this search option it self. You should just call this.GetType() here.

    • MiscData: This is not used at the time.

    Tip

    There are predefined types you can derive from ofr different DisplayTypes to make your life easier. They are StringSearch for DisplayTypes.String, DateSearch for DisplayTypes.Date, IntegerSearch for DisplayTypes.Integer, BooleanSearch for DisplayTypes.Boolean, and CollectionSearch for DisplayTypes.Collection.

Example

This is a working example of a custom Search Option

CopyC#
public class StringNotEqualSearch : ISearchHeader
{
    //Friendly Name shown to the User
    public string Label
    {
        get { return "Not Equal"; }
    }

    //Some information about the search itself
    public SearchDisplayInfo DisplayInfo
    {
        get {
            return new SearchDisplayInfo(
                DisplayTypes.String /* What Display type this header relates too */,
                this.GetType() /*Its own type*/);
             }
    }

    //Performs the search of the vaule agaisnt the searchValue
    public bool Search(object value, string searchValue)
    {
        // Display type is a string so cast this to a string
        string strValue = value as string;
        if (strValue == null)
        {
            throw new ArgumentException("Value must be a string");
        }

        return strValue != searchValue;
    }
}