I'm creating dynamic converter which converts Visual FoxPro expression to C# expressions which are used in Razor views.
FoxPro has contains operator $
a $ b
returns true if a if substring of b like Contains(a,b) :
public static bool Contains(string a, string b)
{
if (a == null || b == null)
return false;
return b.Contains(a);
}
Replacing $
operator with this Contains method call requires creating sophisticated parser. Not sure how this parser can implemented. a$b
can be part of expression, a
and b
can be string expressions.
How to make it work ? Is is possible to implement contains operator ( operator name can changed, parser can emit it easily) ? Or is there some other way to avoid manual conversion of FoxPro expressions ?
Expressions are used in C# Razor Views in ASP.NET MVC4 application.
Update
I can use standard operator, for example %
. How to implement a % b
operator in Razor views for strings which returns true if a contains in b ?