예제 #1
0
        public string Compile(HaJSCompiler compiler, HaJSSwitchFeature feature, bool first)
        {
            if (defCase)
            {
                return("else");
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(first ? "if (" : "else if (");
            if (arbitrary)
            {
                sb.Append(ArbitraryJSTranslator.Translate(compiler, value.Replace("$x", feature.GetLeft(compiler))));
            }
            else
            {
                string[] rvalues = value.Split(",".ToCharArray());
                sb.Append(rvalues.Select(x => feature.Compile(compiler, x)).Aggregate((x, y) => x + " || " + y));
            }
            sb.Append(")");
            return(sb.ToString());
        }
예제 #2
0
 public string Compile(HaJSCompiler compiler)
 {
     args = args.Select(x => x == null ? x : ArbitraryJSTranslator.Translate(compiler, x)).ToList();
     return(feature.Compile(compiler, args.ElementAtOrDefault(0), args.ElementAtOrDefault(1), args.ElementAtOrDefault(2)) + ";");
 }