Example #1
0
        private static void ParseTypeDef(
            XmlReader xmlReader,
            Dictionary <string, string> typeDefs)
        {
            if (xmlReader.AlwaysRead().NodeType == XmlNodeType.Text && xmlReader.Value.StartsWith("typedef"))
            {
                var builder  = new StringBuilder(xmlReader.Value);
                var typeName = default(string);

                while (xmlReader.Read())
                {
                    if (xmlReader.NodeType == XmlNodeType.Element)
                    {
                        var name = xmlReader.Name;
                        var text = xmlReader.ReadText();

                        if (name == "name")
                        {
                            typeName = text;
                        }

                        builder.Append(text);
                    }
                    else if (xmlReader.NodeType.IsText())
                    {
                        builder.Append(xmlReader.Value);
                    }
                    else
                    {
                        break;
                    }
                }

                var typeDef = builder.ToString();

                if (typeDef.Contains('*', StringComparison.Ordinal))
                {
                    typeDefs.Add(typeName, nameof(IntPtr));
                }
                else
                {
                    typeDefs.Add(typeName, typeDef);
                }
                // Console.WriteLine(typeDef);
            }
            else
            {
                xmlReader.Skip();
            }
        }