Created
July 27, 2014 23:53
-
-
Save musicm122/6791da839a6e47e67278 to your computer and use it in GitHub Desktop.
gen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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