示例#1
0
        public string BuildCode(int indented = 0)
        {
            StringBuilder b = new StringBuilder();

            b.Append("function ");
            if (Name != null)
            {
                b.Append(Name);
            }
            b.Append("(");
            for (int i = 0; i < Parameters.Count; i++)
            {
                b.Append(Parameters[i]);
                if (i < Parameters.Count - 1)
                {
                    b.Append(",");
                }
            }
            b.Append(")\n" + JSBuilder.GetIndented(indented) + "{\n");

            b.Append(Code.BuildCode(indented + 1));
            b.Append(JSBuilder.GetIndented(indented) + "}");

            return(b.ToString());
        }
示例#2
0
        public string BuildCode(int indented = 0)
        {
            StringBuilder b = new StringBuilder();

            b.AppendLine("{");

            int i = 0;

            foreach (KeyValuePair <string, object> kv in Properties)
            {
                b.Append(JSBuilder.GetIndented(indented + 1));
                b.Append(kv.Key);
                b.Append(": ");

                b.Append(BuildValue(kv.Value, indented + 1));


                if (i < (Properties.Count - 1))
                {
                    b.Append(",\n");
                }
                else
                {
                    b.Append("\n");
                }
                i++;
            }
            b.Append(JSBuilder.GetIndented(indented) + "}");

            return(b.ToString());
        }
示例#3
0
 public override string BuildCode(int indented = 0)
 {
     if (indented > 0)
     {
         return(Code.Replace("\n", JSBuilder.GetIndented(indented)));
     }
     return(Code);
 }
示例#4
0
        public override string BuildCode(int indented = 0)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("if(" + Condition + ") {\n");
            builder.Append(Body.BuildCode(indented + 1));
            builder.Append(JSBuilder.GetIndented(indented) + "}");
            return(builder.ToString());
        }
示例#5
0
        public string BuildCode(int indented = 0)
        {
            StringBuilder b = new StringBuilder();

            foreach (JSBOperation op in Operations)
            {
                b.AppendLine(JSBuilder.GetIndented(indented) + op.BuildCode(indented));
            }
            return(b.ToString());
        }
示例#6
0
        public override string BuildCode(int indented = 0)
        {
            StringBuilder b = new StringBuilder();

            b.Append(JSBuilder.GetIndented(indented));
            b.Append(VariableName);
            b.Append(" = ");
            if (!IsValueType)
            {
                b.Append(((JSBObject)VariableValue).BuildCode(indented));
            }
            else
            {
                b.Append(JSBObject.BuildValue(VariableValue, indented));
            }
            b.Append(";");
            return(b.ToString());
        }