Exemple #1
0
        public override void Build(XElement node)
        {
            var content = templateContent;

            var name = node.GetAttribute("name");

            Console.WriteLine("Enum " + name);
            var parent = node.GetAttribute("parent");

            EnumInfo myInfo = new EnumInfo(name, parent);

            // Provide Enum Summary if present
            content = node.BuildSummaryFrom("text", content, "//EnumSummary\r\n", 1);

            // Set Enum name
            content = content.Replace("EnumName", name);
            // Set Enum data type
            content = content.Replace("Int32", parent);

            // Build Enum item list
            content = content.Replace("ItemList", BuildEnumItems(node, myInfo));

            TypeTable.AddType(myInfo);

            string outputFile = Path.Combine(outputPath, name + ".cs");

            File.WriteAllText(outputFile, content);
        }
Exemple #2
0
        private void BuildTable(XElement parentNode)
        {
            foreach (XElement node in parentNode.Elements())
            {
                if (node.Name == "type")
                {
                    var name = node.GetAttribute("name");

                    if (TypeTable.TypeExists(name))
                    {
                        throw new Exception("Duplicated Type " + name);
                    }

                    TypeInfo newType = new TypeInfo(name);

                    if (node.HasAttribute("parent"))
                    {
                        newType.Parent = node.GetAttribute("parent");
                    }

                    if (node.HasAttribute("primitive"))
                    {
                        newType.IsPrimitive = node.GetAttribute("primitive") == "true";
                    }

                    if (node.HasAttribute("reader"))
                    {
                        newType.Reader = node.GetAttribute("reader");
                    }

                    if (node.HasAttribute("writer"))
                    {
                        newType.Writer = node.GetAttribute("writer");
                    }

                    if (node.HasAttribute("noTemplate"))
                    {
                        newType.NoTemplate = node.GetAttribute("noTemplate") == "true";
                    }

                    if (node.HasAttribute("integer"))
                    {
                        newType.IsIntegerType = node.GetAttribute("integer") == "true";
                    }

                    if (node.HasAttribute("signed"))
                    {
                        newType.IsSignedType = node.GetAttribute("signed") == "true";
                    }

                    if (node.HasAttribute("baseType"))
                    {
                        newType.BaseType = node.GetAttribute("baseType");
                    }

                    TypeTable.AddType(newType);
                }
            }
        }