forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryEngineAttributes.cs
More file actions
176 lines (158 loc) · 11 KB
/
Copy pathQueryEngineAttributes.cs
File metadata and controls
176 lines (158 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
namespace UnityEditor.Search
{
/// <summary>
/// Base attribute class used to define a custom filter on a QueryEngine.
/// All filter types supported by QueryEngine.AddFilter are supported by this attribute.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class QueryEngineFilterAttribute : Attribute
{
/// <summary>
/// The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").
/// </summary>
public string token;
/// <summary>
/// String comparison options.
/// </summary>
public StringComparison comparisonOptions;
/// <summary>
/// Flag indicating if the filter overrides the global string comparison options.
/// This flag is set to true when the comparisonOptions are used.
/// </summary>
public bool overridesStringComparison;
/// <summary>
/// List of supported operator tokens. Null for all operators.
/// </summary>
public string[] supportedOperators;
/// <summary>
/// Flag indicating if this filter uses a parameter transformer function.
/// This flag is set to true when paramTransformerFunction is used.
/// </summary>
public bool useParamTransformer;
/// <summary>
/// Name of the parameter transformer function to use with this filter.
/// Tag the parameter transformer function with the appropriate ParameterTransformer attribute.
/// </summary>
public string paramTransformerFunction;
/// <summary>
/// Flag indicating if this filter uses a regular expression token.
/// This flag is set to true when <see cref="token"/> is a regular expression.
/// </summary>
public bool useRegularExpressionToken;
internal string propositionReplacement;
/// <summary>
/// Create a filter with the corresponding token and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="supportedOperators">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.</param>
public QueryEngineFilterAttribute(string token, string[] supportedOperators = null)
{
this.token = token;
this.supportedOperators = supportedOperators;
}
/// <summary>
/// Create a filter with the corresponding token, string comparison options and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="options">String comparison options.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>This sets the flag overridesStringComparison to true.</remarks>
public QueryEngineFilterAttribute(string token, StringComparison options, string[] supportedOperators = null)
: this(token, supportedOperators)
{
comparisonOptions = options;
overridesStringComparison = true;
}
/// <summary>
/// Create a filter with the corresponding token, parameter transformer function and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="paramTransformerFunction">Name of the parameter transformer function to use with this filter. Tag the parameter transformer function with the appropriate ParameterTransformer attribute.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>Sets the flag useParamTransformer to true.</remarks>
public QueryEngineFilterAttribute(string token, string paramTransformerFunction, string[] supportedOperators = null)
: this(token, supportedOperators)
{
useParamTransformer = true;
this.paramTransformerFunction = paramTransformerFunction;
}
/// <summary>
/// Create a filter with the corresponding token, parameter transformer function, string comparison options and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="paramTransformerFunction">Name of the parameter transformer function to use with this filter. Tag the parameter transformer function with the appropriate ParameterTransformer attribute.</param>
/// <param name="options">String comparison options.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>Sets both overridesStringComparison and useParamTransformer flags to true.</remarks>
public QueryEngineFilterAttribute(string token, string paramTransformerFunction, StringComparison options, string[] supportedOperators = null)
: this(token, options, supportedOperators)
{
useParamTransformer = true;
this.paramTransformerFunction = paramTransformerFunction;
}
/// <summary>
/// Create a filter with the corresponding regular expression token and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="useRegularExpression">Set this flag to true to specify that <see cref="token"/> is a regular expression.</param>
/// <param name="supportedOperators">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.</param>
public QueryEngineFilterAttribute(string token, bool useRegularExpression, string[] supportedOperators = null)
{
this.token = token;
this.useRegularExpressionToken = useRegularExpression;
this.supportedOperators = supportedOperators;
}
/// <summary>
/// Create a filter with the corresponding regular expression token, string comparison options and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="useRegularExpression">Set this flag to true to specify that <see cref="token"/> is a regular expression.</param>
/// <param name="options">String comparison options.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>This sets the flag overridesStringComparison to true.</remarks>
public QueryEngineFilterAttribute(string token, bool useRegularExpression, StringComparison options, string[] supportedOperators = null)
: this(token, useRegularExpression, supportedOperators)
{
comparisonOptions = options;
overridesStringComparison = true;
}
/// <summary>
/// Create a filter with the corresponding regular expression token, parameter transformer function and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="useRegularExpression">Set this flag to true to specify that <see cref="token"/> is a regular expression.</param>
/// <param name="paramTransformerFunction">Name of the parameter transformer function to use with this filter. Tag the parameter transformer function with the appropriate ParameterTransformer attribute.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>Sets the flag useParamTransformer to true.</remarks>
public QueryEngineFilterAttribute(string token, bool useRegularExpression, string paramTransformerFunction, string[] supportedOperators = null)
: this(token, useRegularExpression, supportedOperators)
{
useParamTransformer = true;
this.paramTransformerFunction = paramTransformerFunction;
}
/// <summary>
/// Create a filter with the corresponding regular expression token, parameter transformer function, string comparison options and supported operators.
/// </summary>
/// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter (for example, "id" in "id>=2").</param>
/// <param name="useRegularExpression">Set this flag to true to specify that <see cref="token"/> is a regular expression.</param>
/// <param name="paramTransformerFunction">Name of the parameter transformer function to use with this filter. Tag the parameter transformer function with the appropriate ParameterTransformer attribute.</param>
/// <param name="options">String comparison options.</param>
/// <param name="supportedOperators">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.</param>
/// <remarks>Sets both overridesStringComparison and useParamTransformer flags to true.</remarks>
public QueryEngineFilterAttribute(string token, bool useRegularExpression, string paramTransformerFunction, StringComparison options, string[] supportedOperators = null)
: this(token, useRegularExpression, options, supportedOperators)
{
useParamTransformer = true;
this.paramTransformerFunction = paramTransformerFunction;
}
}
/// <summary>
/// Base attribute class that defines a custom parameter transformer function.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class QueryEngineParameterTransformerAttribute : Attribute {}
}