예제 #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 JSBFunctionOperation(string name, JSBuilder code, params string[] parameters)
        {
            Type = JSBOperations.Function;

            FunctionName = name;
            Parameters   = parameters.ToList();

            Code = code;
        }
예제 #6
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());
        }
예제 #7
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());
        }
예제 #8
0
 public JSBIf(string condition, string body)
 {
     Condition = condition;
     Body      = new JSBuilder().AddCode(body);
 }
예제 #9
0
 public JSBIf(string condition, JSBuilder body)
 {
     Condition = condition;
     Body      = body;
 }
예제 #10
0
 public JSBuilder AddCode(JSBuilder code)
 {
     Operations.Add(new JSBCustomOperation(code.BuildCode()));
     return(this);
 }
예제 #11
0
 public JSBuilder If(string condition, JSBuilder then)
 {
     Operations.Add(new JSBIf(condition, then));
     return(this);
 }
예제 #12
0
 public JSBuilder DefineFunction(string name, JSBuilder code, params string[] parameters)
 {
     Operations.Add(new JSBFunctionOperation(name, code, parameters));
     return(this);
 }
예제 #13
0
 public JSBFunction(string name, string code, params string[] paras)
 {
     Name       = name;
     Parameters = paras.ToList();
     Code       = new JSBuilder().AddCode(code);
 }
예제 #14
0
 public JSBFunction(string name, JSBuilder code, params string[] paras)
 {
     Name       = name;
     Parameters = paras.ToList();
     Code       = code;
 }
예제 #15
0
 public void AddFunction(string name, JSBuilder builder, params string[] parameters)
 {
     Properties.Add(name, new JSBFunction(null, builder, parameters));
 }