private static bool IsOperator(string filter, int i, out int length, bool previous = false)
{
bool isOperator = false;
length = 0;
if (i < filter.Length - 1)
{
string op = filter.Substring(i - (i >= 2 ? (previous ? 2 : 0) : 0), 1);
if (op == "=" || op == "<" || op == ">")
{
isOperator = true;
length = 1;
}
}
if (!isOperator)
{
if (i < filter.Length - 2)
{
string op = filter.Substring(i - (i >= 3 ? (previous ? 3 : 0) : 0), 2);
if (op == "==" || op == "!=" || op == "<>" || op == "<=" || op == ">=")
{
isOperator = true;
length = 2;
}
}
}
if (!isOperator)
{
if (i < filter.Length - 4)
{
string op = filter.Substring(i - (i >= 5 ? (previous ? 5 : 0) : 0), 4);
if (op.Equals("like", StringComparison.InvariantCultureIgnoreCase))
{
isOperator = true;
length = 4;
}
}
}
if (!isOperator)
{
if (i < filter.Length - 8)
{
string op = filter.Substring(i - (i >= 9 ? (previous ? 9 : 0) : 0), 8);
if (op.Equals("not like", StringComparison.InvariantCultureIgnoreCase))
{
isOperator = true;
length = 8;
}
}
}
return isOperator;
}