Exemplo n.º 1
0
        public static List<Directive> BindingVariables(List<Directive> bufferDirectives, Variable[] variables)
        {
            if (bufferDirectives != null && variables != null)
            {
                StringBuilder declarationVariables = new StringBuilder();

                for (int i = 0; i < variables.Length; i++)
                {
                    if (variables[i].Type.ToString().Equals(ArgumentType.String.ToString()))
                        declarationVariables.Append(" " + variables[i].Value.GetType() + " " + variables[i].Name + " = \"" + variables[i].Value + "\"; ");
                    else
                        if (variables[i].Type.ToString().Equals(ArgumentType.Boolean.ToString()))
                            declarationVariables.Append(" " + variables[i].Value.GetType() + " " + variables[i].Name + " = true; ");
                        else
                            if (variables[i].Type.ToString().Equals(ArgumentType.Double.ToString()))
                                declarationVariables.Append(" " + variables[i].Value.GetType() + " " + variables[i].Name + " = " + variables[i].Value.ToString().Replace(",", ".") + "; ");
                            else
                                declarationVariables.Append(" " + variables[i].Value.GetType() + " " + variables[i].Name + " = " + variables[i].Value + "; ");
                }

                bufferDirectives.Insert(0, new Directive() { Text = declarationVariables.ToString(), IsCode = true });
            }

            return bufferDirectives;
        }
Exemplo n.º 2
0
        public ParserJava(String templateText, String[] namespaces, Variable[] variables, Object[] values)
        {
            this.bufferDirectives = new List<Directive>();

            this.templateText = templateText;
            this.variables = ValidatorSyntaxJava.ValidateVariables(variables, values);
            this.values = values;
            this.namespaces = namespaces;
        }
Exemplo n.º 3
0
        public ParserCSharp(String templateText, String[] namespaces, Variable[] variables, Object[] values)
        {
            this.bufferDirectives = new List<Directive>();

            this.templateText = templateText;
            this.variables = ValidatorSyntaxCSharp.ValidateVariables(variables, values);
            this.values = values;
            this.namespaces = namespaces;

            if(this.namespaces != null)
                if(this.namespaces.Length == 0)
                    this.namespaces = new String[] { "using System;" };
        }
Exemplo n.º 4
0
        public static Variable[] ValidateVariables(Variable[] variables, Object[] values)
        {
            if (variables != null && values != null)
            {
                if (variables.Length != values.Length)
                    throw new Exception();

                for (int i = 0; i < variables.Length; i++)
                {
                    variables[i].Value = values[i];
                }

                return variables;
            }

            return null;
        }
Exemplo n.º 5
0
        public static Variable[] ValidateVariables(Variable[] variables, Object[] values)
        {
            if (variables != null && values != null)
            {
                if (variables.Length != values.Length)
                    throw new Exception();

                for (int i = 0; i < variables.Length; i++)
                {
                    if (values[i].GetType().ToString().Contains(variables[i].Type.ToString()))
                        variables[i].Value = values[i];
                    else
                        throw new Exception();
                }

                return variables;
            }

            return null;
        }
Exemplo n.º 6
0
 public abstract String Parse(String templateText, String[] namespaces, Variable[] variables, object[] values);
Exemplo n.º 7
0
 public String Parse(String templateText, String[] namespaces, Variable[] variables, object[] values)
 {
     return this.lang.Parse(templateText, namespaces, variables, values);
 }
Exemplo n.º 8
0
 public override string Parse(String templateText, String[] namespaces, Variable[] variables, Object[] values)
 {
     this.parserLang = new ParserJava(templateText, namespaces, variables, values);
     return this.parserLang.Parse();
 }