Skip to content

Instantly share code, notes, and snippets.

@musicm122
Created July 27, 2014 23:53
Show Gist options
  • Save musicm122/6791da839a6e47e67278 to your computer and use it in GitHub Desktop.
Save musicm122/6791da839a6e47e67278 to your computer and use it in GitHub Desktop.
gen
public static string CreateCode(Condition node)
{
StringBuilder sb = new StringBuilder();
sb.Append("if(");
while (node!=null)
{
if(node.HasNot)
{
sb.Append("!");
}
sb.Append("val.Contains==");
sb.Append("\""+node.expression+"\" ");
if(node.LogicalOperator!=LogicalOperator.None)
{
sb.Append(GetLogicOperationSymbol(node.LogicalOperator) +" ");
}
node = node.Right;
}
sb.Append(")");
sb.AppendLine("");
sb.AppendLine("{");
sb.AppendLine("//do stuff");
sb.AppendLine("}");
return sb.ToString();
}
public static string GetLogicOperationSymbol(LogicalOperator op)
{
var retval= "";
switch (op)
{
case LogicalOperator.And:
retval= "&&";
break;
case LogicalOperator.Or:
retval= "||";
break;
case LogicalOperator.Not:
retval= "!";
break;
default:
break;
}
return retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment