public static ScriptExpression Parse(string expression)
{
if (String.IsNullOrEmpty(expression)) {
throw new ArgumentNullException("expression");
}
string[] scriptParts = expression.Split('=');
if ((scriptParts != null) && (scriptParts.Length == 1)) {
IValueExpression rhs = ParseExpression(scriptParts[0].Trim(), /* allowMethod */ true);
if (rhs != null) {
return new ScriptExpression(expression, rhs);
}
}
else if (scriptParts.Length == 2) {
IValueExpression rhs = ParseExpression(scriptParts[1].Trim(), /* allowMethod */ true);
IValueExpression lhs = ParseExpression(scriptParts[0].Trim(), /* allowMethod */ false);
if ((rhs != null) && (lhs != null) && (lhs is PropertyAccessExpression)) {
if (((PropertyAccessExpression)lhs).IsValidSetterExpression) {
return new ScriptExpression(expression, rhs, lhs);
}
}
}
return null;
}