コード例 #1
0
        public void TestMethod06_1() // no se encontraron nodos en clases
        {
            csXML model = new csXML("1.0", "UTF-8");

            model.document.references = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });
            model.document.csNamespace.name    = "Test";
            model.document.csNamespace.Classes = new List <csClass>();

            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #2
0
        public static string TranslateToCSharp(csXML model)
        {
            if (model == null)
            {
                throw new TranslateException(ErrorAndExceptionsCatalog._701_Code, ErrorAndExceptionsCatalog._701_ModelNotFound);
            }

            XmlDocument xmlDocument  = SerializeToXML(model);
            string      csSharpModel = SerializeToCSharp(xmlDocument);

            return(csSharpModel);
        }
コード例 #3
0
        public void TestMethod06() // no se encontraron nodos en referencias
        {
            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "Sample0"
                }, csArguments = argList, csLines = null
            });

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name    = "UltimateTest";
            model.document.references          = new List <csReferences>();
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                name = "clase1", partial = "false", inheritance = "false", lines = variables, constructors = constructorList, modifiers = null
            });
            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #4
0
        public void TestMethod06_2() // no se encontraron nodos en constructores
        {
            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "modifier", modifier = "public", isStatic = true, line = 1, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "isStatic", modifier = "public", isStatic = true, line = 2, value = "", type = "bool", lineCode = "", getterOrSetter = true
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            csXML model = new csXML("1.0", "UTF-8");

            model.document.references = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });

            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });
            model.document.csNamespace.name = "Test";
            String             Code     = ErrorAndExceptionsCatalog._706_Code;
            String             Message  = ErrorAndExceptionsCatalog._706_ChildNodesNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #5
0
        public void TestMethod01() // modelo de valor nulo
        {
            //var
            csXML              model    = null;
            String             Code     = ErrorAndExceptionsCatalog._701_Code;
            String             Message  = ErrorAndExceptionsCatalog._701_ModelNotFound;
            TranslateException resultEX = new TranslateException();

            //act
            try {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }
            //arrange
            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #6
0
        public void TestMethod04() // informacion incompleta
        {
            csXML model = new csXML("1.0", "UTF-8");

            model.document.references       = new List <csReferences>();
            model.document.csNamespace.name = "";
            String             Code     = ErrorAndExceptionsCatalog._704_Code;
            String             Message  = ErrorAndExceptionsCatalog._704_NotEnoughInformation;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #7
0
        public void TestMethod03() // tipo de codificación invalido
        {
            csXML model = new csXML();

            model.version  = "1.0";
            model.encoding = "ATF-42";
            String             Code     = ErrorAndExceptionsCatalog._703_Code;
            String             Message  = ErrorAndExceptionsCatalog._703_InvalidEncoding;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #8
0
        public void TestMethod02() // version incorrecta
        {
            csXML model = new csXML();

            model.version  = "2.0";
            model.encoding = "UTF-8";
            String             Code     = ErrorAndExceptionsCatalog._702_Code;
            String             Message  = ErrorAndExceptionsCatalog._702_InvalidVersionModel;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #9
0
        public void TestMethod07() // version nula
        {
            csXML model = new csXML();

            model.version  = "";
            model.encoding = "UTF-8";
            String             Code     = ErrorAndExceptionsCatalog._707_Code;
            String             Message  = ErrorAndExceptionsCatalog._707_ModelVersionNotFound;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #10
0
 public static void XMLStructureValidations(csXML model)
 {
     if (string.IsNullOrEmpty(model.version))
     {
         throw new TranslateException(ErrorAndExceptionsCatalog._707_Code, ErrorAndExceptionsCatalog._707_ModelVersionNotFound);
     }
     else if (!model.version.StartsWith("1"))
     {
         throw new TranslateException(ErrorAndExceptionsCatalog._702_Code, ErrorAndExceptionsCatalog._702_InvalidVersionModel);
     }
     if (!model.encoding.StartsWith("U"))
     {
         throw new TranslateException(ErrorAndExceptionsCatalog._703_Code, ErrorAndExceptionsCatalog._703_InvalidEncoding);
     }
     if (string.IsNullOrEmpty(model.document.csNamespace.name))
     {
         throw new TranslateException(ErrorAndExceptionsCatalog._704_Code, ErrorAndExceptionsCatalog._704_NotEnoughInformation);
     }
     if (model.document.csNamespace.Classes.Count == 0 || model.document.references.Count == 0 || model.document.csNamespace.Classes.First().constructors.Count == 0 || model.document.csNamespace.Classes.First().lines.Count == 0)
     {
         throw new TranslateException(ErrorAndExceptionsCatalog._706_Code, ErrorAndExceptionsCatalog._706_ChildNodesNotFound);
     }
 }
コード例 #11
0
        public void TestMethod05() // no se creó el nodo
        {
            List <csLine> variables = new List <csLine>();

            variables.Add(null);

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(null);

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name = "UnitTest";
            model.document.references       = new List <csReferences>();
            model.document.references.Add(null);
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                name = "clase1", partial = "false", inheritance = "false", lines = variables, constructors = constructorList, modifiers = null
            });
            String             Code     = ErrorAndExceptionsCatalog._705_Code;
            String             Message  = ErrorAndExceptionsCatalog._705_NotCreatedNode;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #12
0
        public void TestMethod015() // el metodo no retorna un valor
        {
            List <csLine> methodLines = new List <csLine>();

            methodLines.Add(new csLine()
            {
                line = 0, lineCode = "var x = 5;", executeMethods = null
            });

            List <csArgument> methodsArgs = new List <csArgument>();

            methodsArgs.Add(new csArgument()
            {
                type = "string", value = "Saludo"
            });

            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csMethods()
            {
                name = "method", arguments = null, isStatic = true, isReturned = false, dataTypeReturn = "string", lines = methodLines, line = 9
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "BaseClass"
                }, csArguments = argList, csLines = null
            });

            csXML model = new csXML("1.0", "UTF-8");

            model.document.csNamespace.name = "UltimateTests";
            model.document.references       = new List <csReferences>();
            model.document.references.Add(new csReferences {
                name = "System;"
            });
            model.document.csNamespace.Classes = new List <csClass>();
            model.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });

            String             Code     = ErrorAndExceptionsCatalog._715_Code;
            String             Message  = ErrorAndExceptionsCatalog._715__ValueIsNotReturnedInMethod;
            TranslateException resultEX = new TranslateException();

            try
            {
                string csObject = XMLToCSharp.TranslateToCSharp(model);
            }
            catch (TranslateException ex)
            {
                resultEX = ex;
            }

            Assert.AreEqual(Code, resultEX.code);
            Assert.AreEqual(Message, resultEX.messageCode);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: jimmySiete/Sensato
        static void Main(string[] args)
        {
            List <csLine> methodLines = new List <csLine>();

            methodLines.Add(new csLine()
            {
                line = 0, lineCode = "var x = 5;", executeMethods = null
            });

            List <csArgument> methodsArgs = new List <csArgument>();

            methodsArgs.Add(new csArgument()
            {
                type = "string", value = "Saludo"
            });
            methodsArgs.Add(new csArgument()
            {
                type = "int", value = "Año"
            });

            List <csLine> variables = new List <csLine>();

            variables.Add(new csVar()
            {
                name = "name", modifier = "public", isStatic = false, line = 0, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "modifier", modifier = "public", isStatic = true, line = 1, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "isStatic", modifier = "public", isStatic = true, line = 2, value = "", type = "bool", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "value", modifier = "public", isStatic = true, line = 3, value = "", type = "object", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "type", modifier = "public", isStatic = true, line = 4, value = "", type = "string", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "getter", modifier = "public", isStatic = true, line = 5, value = "", type = "csGetter", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "setter", modifier = "public", isStatic = true, line = 6, value = "", type = "csSetter", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csVar()
            {
                name = "methods", modifier = "public", isStatic = true, line = 7, value = "", type = "List<csExecuteMethods>", lineCode = "", getterOrSetter = true
            });
            variables.Add(new csMethods()
            {
                name = "Testing", arguments = methodsArgs, isStatic = false, isReturned = false, dataTypeReturn = "void", lines = null, line = 8
            });
            variables.Add(new csMethods()
            {
                name = "AnotherTesting", arguments = null, isStatic = true, isReturned = true, dataTypeReturn = "string", lines = methodLines, line = 9
            });

            List <csArgument> argList = new List <csArgument>();

            argList.Add(new csArgument()
            {
                type = "string", value = "Apellido"
            });
            argList.Add(new csArgument()
            {
                type = "string", value = "Nombre"
            });

            List <csConstructor> constructorList = new List <csConstructor>();

            constructorList.Add(new csConstructor()
            {
                classConstructor = new csClass()
                {
                    name = "Sample0"
                }, csArguments = argList, csLines = null
            });

            csXML xmlModel = new csXML("1.0", "UTF-8");

            xmlModel.document.references = new List <csReferences>();
            xmlModel.document.references.Add(new csReferences {
                name = "System;"
            });
            xmlModel.document.references.Add(new csReferences {
                name = "System.Collections.Generic;"
            });
            xmlModel.document.references.Add(new csReferences()
            {
                name = "System.Text;"
            });
            xmlModel.document.csNamespace = new csNamespace()
            {
                name = "Sensato.Translate.Entities"
            };
            xmlModel.document.csNamespace.Classes = new List <csClass>();
            xmlModel.document.csNamespace.Classes.Add(new csClass()
            {
                inheritance = "BaseSample", name = "Sample0", modifiers = "public", partial = "true", lines = variables, constructors = constructorList
            });
            string csObject = XMLToCSharp.TranslateToCSharp(xmlModel);
        }
コード例 #14
0
        private static XmlDocument SerializeToXML(csXML model)
        {
            XmlDocument newFile = new XmlDocument();  // document creation

            try
            {
                XMLStructureValidations(model);
                XmlDeclaration declaration = newFile.CreateXmlDeclaration(model.version, model.encoding, null);
                XmlElement     heading     = newFile.DocumentElement; //xml declaration
                newFile.InsertBefore(declaration, heading);

                XmlElement document = newFile.CreateElement("document", string.Empty); // document initial structure, where the parts are declared to specify the structure of the document.
                newFile.AppendChild(document);

                XmlElement references   = newFile.CreateElement("references", string.Empty);
                XmlElement namespaces   = newFile.CreateElement("namespace", string.Empty);
                XmlElement finalClass   = newFile.CreateElement("class", string.Empty);
                XmlElement constructors = newFile.CreateElement("constructor", string.Empty);

                if (model.document.references.Count > 0) // in the first level it's declared the tag 'References', after verifying that this attribute exists.
                {
                    document.AppendChild(references);

                    for (var i = 0; i < model.document.references.Count; i++)
                    {
                        XmlElement   usings    = newFile.CreateElement("using", string.Empty); // declaration of the child from 'References' tag.
                        XmlAttribute usingAttr = newFile.CreateAttribute("name");
                        usingAttr.Value = model.document.references[i].name;
                        usings.Attributes.Append(usingAttr);
                        references.AppendChild(usings);
                    }
                }

                if (model.document.csNamespace.name != null) // at the same level that 'References', 'Namespace' tag is added after it. But first we have to verify if the attribute to namespace exists.
                {
                    document.InsertAfter(namespaces, references);
                    XmlAttribute namespaceAttr = newFile.CreateAttribute("name"); // then we add the name of the namespace.
                    namespaceAttr.Value = model.document.csNamespace.name;
                    namespaces.Attributes.Append(namespaceAttr);

                    if (model.document.csNamespace.Classes.Count > 0)            // inside of the 'Namespace' tag, we have to validate if one or more clases exists, it it's true there are inserted.
                    {
                        foreach (var item in model.document.csNamespace.Classes) // for each attribute from 'Classes', a sentence is defines to insert the name and value of the property.
                        {
                            XmlAttribute classAttrInheritance = newFile.CreateAttribute("inheritance");
                            classAttrInheritance.Value = item.inheritance;
                            finalClass.Attributes.Append(classAttrInheritance);

                            XmlAttribute classAttrModifiers = newFile.CreateAttribute("modifiers");
                            classAttrModifiers.Value = item.modifiers;
                            finalClass.Attributes.Append(classAttrModifiers);

                            XmlAttribute classAttrName = newFile.CreateAttribute("name");
                            classAttrName.Value = item.name;
                            finalClass.Attributes.Append(classAttrName);

                            XmlAttribute classAttrPartial = newFile.CreateAttribute("partial");
                            classAttrPartial.Value = item.partial;
                            finalClass.Attributes.Append(classAttrPartial);

                            namespaces.AppendChild(finalClass);
                        }

                        for (var i = 0; i < model.document.csNamespace.Classes.Count(); i++)
                        {
                            if (model.document.csNamespace.Classes[i].constructors.Count > 0)            // we have to declare the list of constructors first, if they are contained in the received model.
                            {
                                foreach (var item in model.document.csNamespace.Classes[i].constructors) // tag created for each constructor inside the classes.
                                {
                                    XmlAttribute constructorClass = newFile.CreateAttribute("class");
                                    constructorClass.Value = model.document.csNamespace.Classes[i].constructors.FirstOrDefault().classConstructor.name;
                                    constructors.Attributes.Append(constructorClass);

                                    if (model.document.csNamespace.Classes[i].constructors.Count == 1 && model.document.csNamespace.Classes[i].constructors[i].csArguments.Any())   // Rule about constructors: if we have one constructor with parameters
                                    {                                                                                                                                               // then we have to add an empty constructor and the other with all the data.
                                        var        args             = model.document.csNamespace.Classes[i].constructors[i].csArguments;
                                        XmlElement emptyConstructor = newFile.CreateElement("constructor", string.Empty);

                                        XmlAttribute constructorNameClass = newFile.CreateAttribute("class");
                                        constructorNameClass.Value = constructorClass.Value;
                                        emptyConstructor.Attributes.Append(constructorNameClass);

                                        XmlAttribute emptyArgs = newFile.CreateAttribute("arguments");
                                        emptyArgs.Value = null;
                                        emptyConstructor.Attributes.Append(emptyArgs);

                                        XmlAttribute emptyLines = newFile.CreateAttribute("lines");
                                        emptyLines.Value = null;
                                        emptyConstructor.Attributes.Append(emptyLines);

                                        finalClass.AppendChild(emptyConstructor);

                                        XmlElement nonEmptyConstructor = newFile.CreateElement("constructor", string.Empty);

                                        XmlAttribute nonEmptyConstructorClass = newFile.CreateAttribute("class");
                                        nonEmptyConstructorClass.Value = constructorClass.Value;
                                        nonEmptyConstructor.Attributes.Append(nonEmptyConstructorClass);

                                        XmlAttribute nonEmptyArgs = newFile.CreateAttribute("arguments");
                                        nonEmptyArgs.Value = ResultantArguments(args);
                                        nonEmptyConstructor.Attributes.Append(nonEmptyArgs);

                                        XmlAttribute constructorLines = newFile.CreateAttribute("lines");
                                        for (var index = 0; index < model.document.csNamespace.Classes[i].constructors.Count; index++) // the same logic is used like in the arguments list.
                                        {
                                            if (model.document.csNamespace.Classes[i].constructors[index].csLines != null)
                                            {
                                                constructorLines.Value = model.document.csNamespace.Classes[i].constructors[index].csLines.ToString();
                                            }
                                            else
                                            {
                                                constructorLines.Value = null;
                                            }
                                            nonEmptyConstructor.Attributes.Append(constructorLines);
                                        }

                                        finalClass.AppendChild(nonEmptyConstructor);
                                    }
                                    else // when we have more than two constructors, these are printed with its elements.
                                    {
                                        XmlAttribute constructorArguments = newFile.CreateAttribute("arguments");

                                        for (var index = 0; index < model.document.csNamespace.Classes[i].constructors.Count; index++)
                                        {
                                            if (model.document.csNamespace.Classes[i].constructors[index].csArguments != null)
                                            {
                                                constructorArguments.Value = ResultantArguments(model.document.csNamespace.Classes[i].constructors[index].csArguments); // iterated arguments are added to the corresponding tag.
                                            }
                                            else
                                            {
                                                constructorArguments.Value = null;
                                            }
                                            constructors.Attributes.Append(constructorArguments);
                                        }

                                        XmlAttribute constructorLines = newFile.CreateAttribute("lines");
                                        for (var index = 0; index < model.document.csNamespace.Classes[i].constructors.Count; index++) // the same logic is used like in the arguments list.
                                        {
                                            if (model.document.csNamespace.Classes[i].constructors[index].csLines.Count > 0)
                                            {
                                                constructorLines.Value = model.document.csNamespace.Classes[i].constructors[index].csLines.ToString();
                                            }
                                            else
                                            {
                                                constructorLines.Value = null;
                                            }
                                            constructors.Attributes.Append(constructorLines);
                                        }
                                        finalClass.AppendChild(constructors);
                                    }
                                }
                            }

                            if (model.document.csNamespace.Classes[i].lines.Count > 0)
                            {
                                foreach (var item in model.document.csNamespace.Classes[i].lines) // for each class, we found variables and methods, depending of the value from the current line we are printing a variable or methods.
                                {
                                    string opts = item.GetType().Name;
                                    switch (opts)
                                    {
                                    case "csVar":
                                        foreach (var varItem in model.document.csNamespace.Classes)
                                        {
                                            var        lineCasterVar = (csVar)item;
                                            XmlElement variables     = newFile.CreateElement("var", string.Empty);

                                            XmlAttribute attrName = newFile.CreateAttribute("name");
                                            attrName.Value = lineCasterVar.name;
                                            variables.Attributes.Append(attrName);

                                            XmlAttribute attrModifier = newFile.CreateAttribute("modifier");
                                            attrModifier.Value = lineCasterVar.modifier;
                                            variables.Attributes.Append(attrModifier);

                                            XmlAttribute attrStatic = newFile.CreateAttribute("isStatic");
                                            attrStatic.Value = lineCasterVar.isStatic.ToString();
                                            variables.Attributes.Append(attrStatic);

                                            XmlAttribute attrValue = newFile.CreateAttribute("value");
                                            attrValue.Value = lineCasterVar.value.ToString();
                                            variables.Attributes.Append(attrValue);

                                            XmlAttribute attrType = newFile.CreateAttribute("type");
                                            attrType.Value = lineCasterVar.type;
                                            variables.Attributes.Append(attrType);

                                            XmlAttribute attrLine = newFile.CreateAttribute("line");
                                            attrLine.Value = lineCasterVar.line.ToString();
                                            variables.Attributes.Append(attrLine);

                                            XmlAttribute attrGetOrSet = newFile.CreateAttribute("getterOrSetter");
                                            attrGetOrSet.Value = lineCasterVar.getterOrSetter.ToString();
                                            variables.Attributes.Append(attrGetOrSet);

                                            finalClass.AppendChild(variables);
                                        }
                                        break;

                                    case "csMethods":
                                        foreach (var methodItem in model.document.csNamespace.Classes)
                                        {
                                            var        lineCasterMethod = (csMethods)item;
                                            XmlElement methods          = newFile.CreateElement("methods", string.Empty);

                                            XmlAttribute methodName = newFile.CreateAttribute("name");
                                            methodName.Value = lineCasterMethod.name;
                                            methods.Attributes.Append(methodName);

                                            XmlAttribute methodArgs = newFile.CreateAttribute("arguments");
                                            if (lineCasterMethod.arguments != null)
                                            {
                                                methodArgs.Value = ResultantArguments(lineCasterMethod.arguments);
                                            }
                                            else
                                            {
                                                methodArgs.Value = null;
                                            }
                                            methods.Attributes.Append(methodArgs);

                                            XmlAttribute isStatic = newFile.CreateAttribute("static");
                                            isStatic.Value = lineCasterMethod.isStatic.ToString();
                                            methods.Attributes.Append(isStatic);

                                            XmlAttribute isReturn = newFile.CreateAttribute("returned");
                                            isReturn.Value = lineCasterMethod.isReturned.ToString();
                                            methods.Attributes.Append(isReturn);

                                            XmlAttribute dataTypeReturn = newFile.CreateAttribute("dataTypeReturn");
                                            dataTypeReturn.Value = lineCasterMethod.dataTypeReturn;
                                            methods.Attributes.Append(dataTypeReturn);

                                            XmlAttribute methodLines = newFile.CreateAttribute("lines");
                                            if (lineCasterMethod.lines.Count > 0)                // lines of code are contained inside the methods, at the same time we have to insert the lineMethod node.
                                            {
                                                foreach (var lineItem in lineCasterMethod.lines) // inside the method it is the lines of code contained in the model.
                                                {
                                                    XmlElement   lineMethod = newFile.CreateElement("line", string.Empty);
                                                    XmlAttribute line       = newFile.CreateAttribute("number");
                                                    line.Value = lineItem.line.ToString();
                                                    lineMethod.Attributes.Append(line);
                                                    XmlAttribute lineChain = newFile.CreateAttribute("chain");
                                                    lineChain.Value = lineItem.lineCode;
                                                    lineMethod.Attributes.Append(lineChain);
                                                    // then we have to complete the attribute 'execute methods' bc don't remember how this part works.
                                                    methods.AppendChild(lineMethod);
                                                }
                                                methodLines.Value = lineCasterMethod.lines.ToString();
                                            }
                                            else
                                            {
                                                methodLines.Value = null;
                                            }
                                            methods.Attributes.Append(methodLines);
                                            finalClass.AppendChild(methods);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                //newFile.Save("C:/Users/Carolina Martinez/Desktop/ConstructorSample.xml"); // this line is only enabled when we update the code or to test new specifications.
                return(newFile);
            }
            catch (Exception ex)
            {
                XMLStructureValidations(model);
                if (ex != null)
                {
                    throw new TranslateException(ErrorAndExceptionsCatalog._705_Code, ErrorAndExceptionsCatalog._705_NotCreatedNode);
                }
                return(newFile);
            }
        }