Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string XMLFilePath;

            if (args.Length == 1)
            {
                XMLFilePath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(args[0]));
            }
            else
            {
                XMLFilePath = Path.GetFullPath(@"..\..\..\..\..\modded mayors snippet.xml");
            }

            SpreadsheetGenerator generator = new SpreadsheetGenerator(XMLFilePath);


            if (generator.tables.Count > 1)
            {
                string pathPrefix = Path.ChangeExtension(XMLFilePath, null);
                foreach (string table in generator.tables.Keys)
                {
                    generator.WriteTable(table, pathPrefix + "_" + table + ".tsv", '\t');
                }
            }
            else
            {
                generator.WriteTable("Mayors", Path.ChangeExtension(XMLFilePath, "csv"));
            }
        }
Ejemplo n.º 2
0
        private void ReadRows(XElement properties)
        {
            rows = new LinkedList <List <string> >();
            XElement tempRows = (from d in properties.Elements("Dictionary")
                                 where d.Attribute("name").Value == "Rows"
                                 select d).Single();

            foreach (var i in tempRows.Element("Items").Elements("Item"))
            {
                List <string> row = new List <string>(columns.Count);

                int c = 1;
                foreach (var r in i.Element("SingleArray").Element("Items").Elements())
                {
                    if (r.Name == "Simple")
                    {
                        string value = r.Attribute("value").Value;
                        // Prettify IDBonusTechnologies, IDBonusEntities, Mods
                        //row.Add( c > columns.Count - 3 ? SpreadsheetGenerator.PrettyPrint( value ) : value );   // '"' + value + '"'
                        row.Add(SpreadsheetGenerator.PrettyPrint(value));
                    }
                    else
                    {
                        row.Add("");
                    }

                    c++;
                }

                /*
                 * // Sanity check the Item 'dictionary' of Simple:SingleArray key:value pairings?
                 * if( i.Element( "Simple" ).Attribute( "value" ).Value != row[0] )
                 * {
                 *  Console.WriteLine( "ID key does not match first column value: " + row[0] );
                 * }
                 */
                rows.AddLast(row);
            }

            Console.WriteLine("rows: " + rows.Count);
        }