docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class QueryEngine<TData>

    A QueryEngine defines how to build a query from an input string. It can be customized to support custom filters and operators.

    Inheritance
    object
    QueryEngine<TData>
    QueryEngine
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEditor.Search
    Assembly: com.unity.quicksearch.dll
    Syntax
    public class QueryEngine<TData>
    Type Parameters
    Name Description
    TData

    The filtered data type.

    Constructors

    QueryEngine()

    Construct a new QueryEngine.

    Declaration
    public QueryEngine()

    QueryEngine(bool)

    Construct a new QueryEngine.

    Declaration
    public QueryEngine(bool validateFilters)
    Parameters
    Type Name Description
    bool validateFilters

    Indicates if the engine must validate filters when parsing the query.

    QueryEngine(QueryValidationOptions)

    Construct a new QueryEngine with the specified validation options.

    Declaration
    public QueryEngine(QueryValidationOptions validationOptions)
    Parameters
    Type Name Description
    QueryValidationOptions validationOptions

    The validation options to use in this engine.

    Properties

    globalStringComparison

    Global string comparison options for word matching and filter handling (if not overridden).

    Declaration
    public StringComparison globalStringComparison { get; }
    Property Value
    Type Description
    StringComparison

    searchDataCallback

    The callback used to get the data to match to the search words.

    Declaration
    public Func<TData, IEnumerable<string>> searchDataCallback { get; }
    Property Value
    Type Description
    Func<TData, IEnumerable<string>>

    searchDataOverridesStringComparison

    Indicates if word/phrase matching uses searchDataStringComparison or not.

    Declaration
    public bool searchDataOverridesStringComparison { get; }
    Property Value
    Type Description
    bool

    searchDataStringComparison

    String comparison options for word/phrase matching.

    Declaration
    public StringComparison searchDataStringComparison { get; }
    Property Value
    Type Description
    StringComparison

    searchWordMatcher

    The function used to match the search data against the search words.

    Declaration
    public Func<string, bool, StringComparison, string, bool> searchWordMatcher { get; }
    Property Value
    Type Description
    Func<string, bool, StringComparison, string, bool>

    skipIncompleteFilters

    Boolean indicating if incomplete filters should be skipped. If skipIncompleteFilters is false, incomplete filters will generate errors when parsed.

    Declaration
    public bool skipIncompleteFilters { get; set; }
    Property Value
    Type Description
    bool

    skipUnknownFilters

    Boolean indicating if unknown filters should be skipped. If validateFilters is true and skipUnknownFilters is false, unknown filters will generate errors if no default handler is provided.

    Declaration
    public bool skipUnknownFilters { get; set; }
    Property Value
    Type Description
    bool

    validateFilters

    Get of set if the engine must validate filters when parsing the query. Defaults to true.

    Declaration
    public bool validateFilters { get; set; }
    Property Value
    Type Description
    bool

    Methods

    AddFilter<TFilter>(string, Func<TData, string, TFilter, bool>, string[])

    Add a new custom filter with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public void AddFilter<TFilter>(string token, Func<TData, string, TFilter, bool> filterResolver, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TFilter>(string, Func<TData, TFilter>, StringComparison, string[])

    Add a new custom filter.

    Declaration
    public void AddFilter<TFilter>(string token, Func<TData, TFilter> getDataFunc, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and returns an object of type TFilter.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TFilter>(string, Func<TData, TFilter>, string[])

    Add a new custom filter.

    Declaration
    public void AddFilter<TFilter>(string token, Func<TData, TFilter> getDataFunc, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and returns an object of type TFilter.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TFilter>(Regex, Func<TData, string, string, TFilter, bool>, string[])

    Add a new custom filter with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public IQueryEngineFilter AddFilter<TFilter>(Regex token, Func<TData, string, string, TFilter, bool> filterResolver, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, a string representing the actual filter name that was matched, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TFilter>(Regex, Func<TData, string, TFilter>, StringComparison, string[])

    Add a new custom filter.

    Declaration
    public IQueryEngineFilter AddFilter<TFilter>(Regex token, Func<TData, string, TFilter> getDataFunc, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched and returns an object of type TFilter.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TFilter>(Regex, Func<TData, string, TFilter>, string[])

    Add a new custom filter.

    Declaration
    public IQueryEngineFilter AddFilter<TFilter>(Regex token, Func<TData, string, TFilter> getDataFunc, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched and returns an object of type TFilter.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, string, TFilter, bool>, Func<string, TParam>, string[])

    Add a new custom filter function with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, string, TFilter, bool> filterResolver, Func<string, TParam> parameterTransformer, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, an object of type TParam, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, string, TFilter, bool>, string[])

    Add a new custom filter function with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, string, TFilter, bool> filterResolver, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, an object of type TParam, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, TFilter>, Func<string, TParam>, StringComparison, string[])

    Add a new custom filter function.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, TFilter> getDataFunc, Func<string, TParam> parameterTransformer, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and TParam, and returns an object of type TFilter.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, TFilter>, Func<string, TParam>, string[])

    Add a new custom filter function.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, TFilter> getDataFunc, Func<string, TParam> parameterTransformer, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and TParam, and returns an object of type TFilter.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, TFilter>, StringComparison, string[])

    Add a new custom filter function.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, TFilter> getDataFunc, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and TParam, and returns an object of type TFilter.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(string, Func<TData, TParam, TFilter>, string[])

    Add a new custom filter function.

    Declaration
    public void AddFilter<TParam, TFilter>(string token, Func<TData, TParam, TFilter> getDataFunc, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData and TParam, and returns an object of type TFilter.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, string, TFilter, bool>, Func<string, TParam>, string[])

    Add a new custom filter function with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, string, TFilter, bool> filterResolver, Func<string, TParam> parameterTransformer, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, string, TFilter, bool>, string[])

    Add a new custom filter function with a custom resolver. Useful when you wish to handle all operators yourself.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, string, TFilter, bool> filterResolver, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, string, TFilter, bool> filterResolver

    Callback used to handle any operators for this filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, the operator token and the filter value, and returns a boolean indicating if the filter passed or not.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, TFilter>, Func<string, TParam>, StringComparison, string[])

    Add a new custom filter function.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, TFilter> getDataFunc, Func<string, TParam> parameterTransformer, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, and returns an object of type TFilter.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, TFilter>, Func<string, TParam>, string[])

    Add a new custom filter function.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, TFilter> getDataFunc, Func<string, TParam> parameterTransformer, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, and returns an object of type TFilter.

    Func<string, TParam> parameterTransformer

    Callback used to convert a string to the type TParam. Used when parsing the query to convert what is passed to the function into the correct format.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, TFilter>, StringComparison, string[])

    Add a new custom filter function.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, TFilter> getDataFunc, StringComparison stringComparison, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, and returns an object of type TFilter.

    StringComparison stringComparison

    String comparison options.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFilter<TParam, TFilter>(Regex, Func<TData, string, TParam, TFilter>, string[])

    Add a new custom filter function.

    Declaration
    public IQueryEngineFilter AddFilter<TParam, TFilter>(Regex token, Func<TData, string, TParam, TFilter> getDataFunc, string[] supportedOperatorType = null)
    Parameters
    Type Name Description
    Regex token

    The regular expression that matches the filter. Matches what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TData, string, TParam, TFilter> getDataFunc

    Callback used to get the object that is used in the filter. Takes an object of type TData, a string representing the actual filter name that was matched, an object of type TParam, and returns an object of type TFilter.

    string[] supportedOperatorType

    List of supported operator tokens. This list contains the supported operator tokens. Use null or an empty list to indicate that all operators are supported.

    Returns
    Type Description
    IQueryEngineFilter

    A IQueryEngineFilter.

    Type Parameters
    Name Description
    TParam

    The type of the constant parameter passed to the function.

    TFilter

    The type of the data that is compared by the filter.

    AddFiltersFromAttribute<TFilterAttribute, TTransformerAttribute>()

    Add all custom filters that are identified with the method attribute TAttribute.

    Declaration
    public void AddFiltersFromAttribute<TFilterAttribute, TTransformerAttribute>() where TFilterAttribute : QueryEngineFilterAttribute where TTransformerAttribute : QueryEngineParameterTransformerAttribute
    Type Parameters
    Name Description
    TFilterAttribute

    The type of the attribute of filters to fetch.

    TTransformerAttribute

    The attribute type for the parameter transformers associated with the filter attribute.

    AddNestedQueryAggregator<TNestedQueryData>(string, Func<IEnumerable<TNestedQueryData>, IEnumerable<TNestedQueryData>>)

    Add a new nested query aggregator. An aggregator is an operation that can be applied on a nested query to aggregate the results of the nested query according to a certain criteria.

    Declaration
    public void AddNestedQueryAggregator<TNestedQueryData>(string token, Func<IEnumerable<TNestedQueryData>, IEnumerable<TNestedQueryData>> aggregator)
    Parameters
    Type Name Description
    string token

    Name of the aggregator used when typing the query. This name will be lowercased when parsing the query to speedup the process.

    Func<IEnumerable<TNestedQueryData>, IEnumerable<TNestedQueryData>> aggregator

    Aggregator function. Takes the results of the nested query, and returns an aggregate that contains any number of items.

    Type Parameters
    Name Description
    TNestedQueryData

    The type of data returned by the nested query.

    AddOperator(string)

    Add a global custom filter operator.

    Declaration
    public void AddOperator(string op)
    Parameters
    Type Name Description
    string op

    The operator identifier.

    AddOperatorHandler<TFilterVariable, TFilterConstant>(string, Func<TFilterVariable, TFilterConstant, bool>)

    Add a custom filter operator handler.

    Declaration
    public void AddOperatorHandler<TFilterVariable, TFilterConstant>(string op, Func<TFilterVariable, TFilterConstant, bool> handler)
    Parameters
    Type Name Description
    string op

    The filter operator.

    Func<TFilterVariable, TFilterConstant, bool> handler

    Callback to handle the operation. Takes a TFilterVariable (value returned by the filter handler, will vary for each element) and a TFilterConstant (right hand side value of the operator, which is constant), and returns a boolean indicating if the filter passes or not.

    Type Parameters
    Name Description
    TFilterVariable

    The operator's left hand side type. This is the type returned by a filter handler.

    TFilterConstant

    The operator's right hand side type.

    AddOperatorHandler<TFilterVariable, TFilterConstant>(string, Func<TFilterVariable, TFilterConstant, StringComparison, bool>)

    Add a custom filter operator handler.

    Declaration
    public void AddOperatorHandler<TFilterVariable, TFilterConstant>(string op, Func<TFilterVariable, TFilterConstant, StringComparison, bool> handler)
    Parameters
    Type Name Description
    string op

    The filter operator.

    Func<TFilterVariable, TFilterConstant, StringComparison, bool> handler

    Callback to handle the operation. Takes a TFilterVariable (value returned by the filter handler, will vary for each element), a TFilterConstant (right hand side value of the operator, which is constant), a StringComparison option and returns a boolean indicating if the filter passes or not.

    Type Parameters
    Name Description
    TFilterVariable

    The operator's left hand side type. This is the type returned by a filter handler.

    TFilterConstant

    The operator's right hand side type.

    AddTypeParser<TFilterConstant>(Func<string, ParseResult<TFilterConstant>>)

    Add a global type parser that parses a string and returns a custom type. Used by custom operator handlers.

    Declaration
    public void AddTypeParser<TFilterConstant>(Func<string, ParseResult<TFilterConstant>> parser)
    Parameters
    Type Name Description
    Func<string, ParseResult<TFilterConstant>> parser

    Callback used to determine if a string can be converted into TFilterConstant. Takes a string and returns a ParseResult object. This contains the success flag, and the actual converted value if it succeeded.

    Type Parameters
    Name Description
    TFilterConstant

    The type of the parsed operand that is on the right hand side of the operator.

    ClearFilters()

    Removes all filters that were added on the QueryEngine.

    Declaration
    public void ClearFilters()

    GetAllFilters()

    Declaration
    public IEnumerable<IQueryEngineFilter> GetAllFilters()
    Returns
    Type Description
    IEnumerable<IQueryEngineFilter>

    GetOperator(string)

    Get a custom operator added on the QueryEngine.

    Declaration
    public QueryFilterOperator GetOperator(string op)
    Parameters
    Type Name Description
    string op

    The operator identifier.

    Returns
    Type Description
    QueryFilterOperator

    The global QueryFilterOperator or an invalid QueryFilterOperator if it does not exist.

    Parse(string, bool)

    Parse a query string into a Query operation. This Query operation can then be used to filter any data set of type TData.

    Declaration
    public Query<TData> Parse(string text, bool useFastYieldingQueryHandler = false)
    Parameters
    Type Name Description
    string text

    The query input string.

    bool useFastYieldingQueryHandler

    Set to true to get a query that will yield null results for elements that don't pass the query, instead of only the elements that pass the query.

    Returns
    Type Description
    Query<TData>

    Query operation of type TData.

    Parse<TQueryHandler, TPayload>(string, IQueryHandlerFactory<TData, TQueryHandler, TPayload>)

    Parse a query string into a Query operation. This Query operation can then be used to filter any data set of type TData.

    Declaration
    public Query<TData, TPayload> Parse<TQueryHandler, TPayload>(string text, IQueryHandlerFactory<TData, TQueryHandler, TPayload> queryHandlerFactory) where TQueryHandler : IQueryHandler<TData, TPayload> where TPayload : class
    Parameters
    Type Name Description
    string text

    The query input string.

    IQueryHandlerFactory<TData, TQueryHandler, TPayload> queryHandlerFactory

    A factory object that creates query handlers of type TQueryHandler. See IQueryHandlerFactory.

    Returns
    Type Description
    Query<TData, TPayload>

    Query operation of type TData and TPayload.

    Type Parameters
    Name Description
    TQueryHandler

    Type of the underlying query handler. See IQueryHandler.

    TPayload

    Type of the payload that the query handler receives.

    RemoveFilter(string)

    Remove a custom filter.

    Declaration
    public void RemoveFilter(string token)
    Parameters
    Type Name Description
    string token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Remarks

    You will get a warning if you try to remove a filter that does not exist.

    RemoveFilter(Regex)

    Remove a custom filter.

    Declaration
    public void RemoveFilter(Regex token)
    Parameters
    Type Name Description
    Regex token

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Remarks

    You will get a warning if you try to remove a filter that does not exist.

    RemoveFilter(IQueryEngineFilter)

    Remove a custom filter.

    Declaration
    public void RemoveFilter(IQueryEngineFilter filter)
    Parameters
    Type Name Description
    IQueryEngineFilter filter

    A IQueryEngineFilter that was returned by AddFilter(string, string[]).

    RemoveOperator(string)

    Removes a custom operator that was added on the QueryEngine.

    Declaration
    public void RemoveOperator(string op)
    Parameters
    Type Name Description
    string op

    The operator identifier.

    SetDefaultFilter(Func<TData, string, string, string, bool>)

    Set the default filter handler for filters that were not registered.

    Declaration
    public void SetDefaultFilter(Func<TData, string, string, string, bool> handler)
    Parameters
    Type Name Description
    Func<TData, string, string, string, bool> handler

    Callback used to handle the filter. Takes an object of type TData, the filter identifier, the operator and the filter value, and returns a boolean indicating if the filter passed or not.

    SetDefaultParamFilter(Func<TData, string, string, string, string, bool>)

    Set the default filter handler for function filters that were not registered.

    Declaration
    public void SetDefaultParamFilter(Func<TData, string, string, string, string, bool> handler)
    Parameters
    Type Name Description
    Func<TData, string, string, string, string, bool> handler

    Callback used to handle the function filter. Takes an object of type TData, the filter identifier, the parameter, the operator and the filter value, and returns a boolean indicating if the filter passed or not.

    SetFilterNestedQueryTransformer<TNestedQueryData, TRhs>(string, Func<TNestedQueryData, TRhs>)

    Set a filter's nested query transformer function. This function takes the result of a nested query and extract the necessary data to compare with the filter.

    Declaration
    public void SetFilterNestedQueryTransformer<TNestedQueryData, TRhs>(string filterToken, Func<TNestedQueryData, TRhs> transformer)
    Parameters
    Type Name Description
    string filterToken

    The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").

    Func<TNestedQueryData, TRhs> transformer

    The transformer function.

    Type Parameters
    Name Description
    TNestedQueryData

    The type of data returned by the nested query.

    TRhs

    The type expected on the right hand side of the filter.

    SetGlobalStringComparisonOptions(StringComparison)

    Set global string comparison options. Used for word matching and filter handling (unless overridden by filter).

    Declaration
    public void SetGlobalStringComparisonOptions(StringComparison stringComparison)
    Parameters
    Type Name Description
    StringComparison stringComparison

    String comparison options.

    SetNestedQueryHandler<TNestedQueryData>(Func<string, string, IEnumerable<TNestedQueryData>>)

    Set the function that will handle nested queries. Only one handler can be set.

    Declaration
    public void SetNestedQueryHandler<TNestedQueryData>(Func<string, string, IEnumerable<TNestedQueryData>> handler)
    Parameters
    Type Name Description
    Func<string, string, IEnumerable<TNestedQueryData>> handler

    The function that handles nested queries. It receives the nested query and the filter token on which the query is applied, and returns an IEnumerable.

    Type Parameters
    Name Description
    TNestedQueryData

    The type of data returned by the nested query.

    SetSearchDataCallback(Func<TData, IEnumerable<string>>)

    Set the callback to be used to fetch the data that will be matched against the search words.

    Declaration
    public void SetSearchDataCallback(Func<TData, IEnumerable<string>> getSearchDataCallback)
    Parameters
    Type Name Description
    Func<TData, IEnumerable<string>> getSearchDataCallback

    Callback used to get the data to be matched against the search words. Takes an object of type TData and return an IEnumerable of strings.

    SetSearchDataCallback(Func<TData, IEnumerable<string>>, Func<string, string>, StringComparison)

    Set the callback to be used to fetch the data that will be matched against the search words, plus a transformer on those words.

    Declaration
    public void SetSearchDataCallback(Func<TData, IEnumerable<string>> getSearchDataCallback, Func<string, string> searchWordTransformerCallback, StringComparison stringComparison)
    Parameters
    Type Name Description
    Func<TData, IEnumerable<string>> getSearchDataCallback

    Callback used to get the data to be matched against the search words. Takes an object of type TData and return an IEnumerable of strings.

    Func<string, string> searchWordTransformerCallback

    Callback used to transform a search word during the query parsing. Useful when doing lowercase or uppercase comparison. Can return null or an empty string to remove the word from the query.

    StringComparison stringComparison

    String comparison options.

    SetSearchDataCallback(Func<TData, IEnumerable<string>>, StringComparison)

    Set the callback to be used to fetch the data that will be matched against the search words.

    Declaration
    public void SetSearchDataCallback(Func<TData, IEnumerable<string>> getSearchDataCallback, StringComparison stringComparison)
    Parameters
    Type Name Description
    Func<TData, IEnumerable<string>> getSearchDataCallback

    Callback used to get the data to be matched against the search words. Takes an object of type TData and return an IEnumerable of strings.

    StringComparison stringComparison

    String comparison options.

    SetSearchWordMatcher(Func<string, bool, StringComparison, string, bool>)

    Set the search word matching function to be used instead of the default one. Set to null to use the default.

    Declaration
    public void SetSearchWordMatcher(Func<string, bool, StringComparison, string, bool> wordMatcher)
    Parameters
    Type Name Description
    Func<string, bool, StringComparison, string, bool> wordMatcher

    The search word matching function. The first parameter is the search word. The second parameter is a boolean for exact match or not. The third parameter is the StringComparison options. The fourth parameter is an element of the array returned by the search data callback. The function returns true for a match or false for no match.

    TryGetFilter(string, out IQueryEngineFilter)

    Try to get a filter by its token.

    Declaration
    public bool TryGetFilter(string token, out IQueryEngineFilter filter)
    Parameters
    Type Name Description
    string token

    The token used to create the filter.

    IQueryEngineFilter filter

    The existing IQueryEngineFilter, or null if it does not exist.

    Returns
    Type Description
    bool

    Returns true if the filter was retrieved or false if the filter does not exist.

    TryGetFilter(Regex, out IQueryEngineFilter)

    Try to get a filter by its token.

    Declaration
    public bool TryGetFilter(Regex token, out IQueryEngineFilter filter)
    Parameters
    Type Name Description
    Regex token

    The token used to create the filter.

    IQueryEngineFilter filter

    The existing IQueryEngineFilter, or null if it does not exist.

    Returns
    Type Description
    bool

    Returns true if the filter was retrieved or false if the filter does not exist.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)