Version: 2021.3
言語: 日本語
public Search.QueryFilterOperator AddHandler (Func<TFilterVariable,TFilterConstant,bool> handler);
public Search.QueryFilterOperator AddHandler (Func<TFilterVariable,TFilterConstant,stringComparison,bool> handler);

パラメーター

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

戻り値

QueryFilterOperator The current QueryFilterOperator.

説明

Adds a custom filter operator handler.

<TFilterVariable>: The type of the operator's left-hand side operand. This is the type returned by a filter handler.

<TFilterConstant>: The type of the operator's right-hand side operand.

An operator handler is a function that is executed for a particular operator (for example "=") with specific type requirements. The operator handler is chosen by the return value of the filter handler (see AddFilter) that is identified when parsing the query, and the type of the filter value.

// Add a new modulo operator on this filter
var op = "%";
queryEngine.TryGetFilter("id", out var filter);
filter.AddOperator(op)
    .AddHandler((int ev, int fv) => ev % fv == 0)
    .AddHandler((float ev, float fv) => Math.Abs(ev % fv) < 0.00000001f);
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961