Exemplo n.º 1
0
        public static void OutputTypeNames()
        {
            // Create XML mapping GomType IDs to names
            var outFilePath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "gom_type_names.xml");

            using (XmlTextWriter writer = new XmlTextWriter(outFilePath, Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("gom_types");

                foreach (var nodeTypeMap in nodeLookup)
                {
                    Type domType = nodeTypeMap.Key;
                    if (domType == typeof(GomObject))
                    {
                        continue;
                    }

                    foreach (var kvp in nodeTypeMap.Value)
                    {
                        DomType t    = kvp.Value;
                        string  name = kvp.Key;

                        writer.WriteStartElement("gom_type");
                        writer.WriteAttributeString("id", t.Id.ToString());
                        writer.WriteAttributeString("name", name);
                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }
Exemplo n.º 2
0
        private static void AddToNameLookup(DomType type)
        {
            if (String.IsNullOrEmpty(type.Name))
            {
                return;
            }

            Dictionary <string, DomType> nameMap;
            Type typeType = type.GetType();

            if (!nodeLookup.TryGetValue(typeType, out nameMap))
            {
                nameMap = new Dictionary <string, DomType>();
                nodeLookup[typeType] = nameMap;
            }

            nameMap.Add(type.Name, type);
        }