Version: Unity 6.1 Alpha (6000.1)
LanguageEnglish
  • C#

SearchExpressionType

enumeration

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Type used to characterize an expression. An expression might have multiple types. For example a Set is also an iterable. A keyword is also considered a string value. SearchExpressionType can be used with SearchExpressionEvaluatorAttribute to describe the parameter list of an evaluator.

[SearchExpressionEvaluator(SearchExpressionType.Iterable | SearchExpressionType.Variadic)]
[SearchExpressionEvaluatorSignatureOverload(SearchExpressionType.Number, SearchExpressionType.Iterable | SearchExpressionType.Variadic)]
[Description("Extract and returns the X first results for each expression.")]
public static IEnumerable<SearchItem> TakeXFirst(SearchExpressionContext c)
{
    var argIndex = 0;
    var takeNumber = 1;
    if (c.args[0].types.HasFlag(SearchExpressionType.Number))
    {
        ++argIndex;
        takeNumber = Math.Max((int)(c.args[0].GetNumberValue(takeNumber)), 0);
    }

    for ( ; argIndex < c.args.Length; ++argIndex)
    {
        var iterable = c.args[argIndex].Execute(c);
        var taken = 0;
        foreach (var item in iterable)
        {
            if (item == null)
                yield return null;
            else
            {
                yield return item;
                ++taken;
                if (taken == takeNumber)
                {
                    c.Break();
                    break;
                }
            }
        }
    }
}

Properties

NilDenote an invalid Expression.
OptionalUsed in SearchExpressionEvaluatorAttribute to specify a aprameter to be Optional.
VariadicUsed in SearchExpressionEvaluatorAttribute to specify that a parameter can be used multiples times. For example count{Iterable1, Iterable2,... IterableN} can be executed with any number of iterables are parameters.
BooleanDenote a Literal expression of a boolean value.
NumberDenote a Literal expression of a numerical value.
TextDenote an expression representing a textual (string) value.
SelectorDenote an expression representing a selector. All selector starts with @. For example @size in expression: select{t:material, @size}.
KeywordDenote an expression yielding a SearchExpressionKeyword.
SetDenote an iterable expression of a group of generally literal values. For example [1, 2, 3] or [material, shader, texture2d].
FunctionDenotes an expression of an evaluator function. For example: count{}.
QueryStringDenote an expression representing a query string. For example: t:shader.
ExpandableDenotes an expression using the ... operator to tell it can be expanded.
GroupDenote an expression of a group of items. Groups are generated by the groupBy{} evaluator.
LiteralDenote an expression built from a literal values: boolean, number, text or keyword. For example in the set expression [1,"hello",true] all set values are literals.
IterableDenote an expression that can iterated to yield SearchItem. Set: [1, 2, 3], Query String: t:shader and evaluator: count{} are all example of iterables.
AnyValueDenote an expression with a value type: either Literal or Iterable.
AnyExpressionDenote any expression of any type (Literal, Iterable or Selector).