Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Eval() [2/3]

override object System.Data.LikeNode.Eval ( DataRow row,
DataRowVersion version )
inlinepackage

Definition at line 21 of file LikeNode.cs.

22 {
23 object obj = _left.Eval(row, version);
25 {
26 return DBNull.Value;
27 }
28 string text;
29 if (_pattern == null)
30 {
31 object obj2 = _right.Eval(row, version);
32 if (!(obj2 is string) && !(obj2 is SqlString))
33 {
34 SetTypeMismatchError(_op, obj.GetType(), obj2.GetType());
35 }
36 if (obj2 == DBNull.Value || DataStorage.IsObjectSqlNull(obj2))
37 {
38 return DBNull.Value;
39 }
40 string pat = (string)SqlConvert.ChangeType2(obj2, StorageType.String, typeof(string), base.FormatProvider);
41 text = AnalyzePattern(pat);
42 if (_right.IsConstant())
43 {
44 _pattern = text;
45 }
46 }
47 else
48 {
49 text = _pattern;
50 }
51 if (!(obj is string) && !(obj is SqlString))
52 {
53 SetTypeMismatchError(_op, obj.GetType(), typeof(string));
54 }
55 string text2 = ((obj is SqlString sqlString) ? sqlString.Value : ((string)obj));
56 string s = text2.TrimEnd(s_trimChars);
57 switch (_kind)
58 {
59 case 5:
60 return true;
61 case 4:
62 return base.table.Compare(s, text) == 0;
63 case 3:
64 return 0 <= base.table.IndexOf(s, text);
65 case 1:
66 return base.table.IndexOf(s, text) == 0;
67 case 2:
68 {
69 string s2 = text.TrimEnd(s_trimChars);
70 return base.table.IsSuffix(s, s2);
71 }
72 default:
73 return DBNull.Value;
74 }
75 }
ExpressionNode _left
Definition BinaryNode.cs:51
void SetTypeMismatchError(int op, Type left, Type right)
ExpressionNode _right
Definition BinaryNode.cs:53
static bool IsObjectSqlNull(object value)
static object ChangeType2(object value, StorageType stype, Type type, IFormatProvider formatProvider)
static readonly char[] s_trimChars
Definition LikeNode.cs:9
string AnalyzePattern(string pat)
Definition LikeNode.cs:77

References System.Data.LikeNode._kind, System.Data.BinaryNode._left, System.Data.BinaryNode._op, System.Data.LikeNode._pattern, System.Data.BinaryNode._right, System.Data.LikeNode.AnalyzePattern(), System.Data.Common.SqlConvert.ChangeType2(), System.Data.ExpressionNode.Eval(), System.Data.ExpressionNode.IsConstant(), System.Data.Common.DataStorage.IsObjectSqlNull(), System.Data.ExpressionNode.IsSqlColumn, System.obj, System.s, System.Data.LikeNode.s_trimChars, System.Data.BinaryNode.SetTypeMismatchError(), System.text, and System.DBNull.Value.