forked from atsushieno/monodroid-schema-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert-csv.cs
executable file
·36 lines (34 loc) · 895 Bytes
/
convert-csv.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.IO;
using System.Linq;
using System.Xml;
public class CsvConvert
{
public static void Main ()
{
Console.WriteLine ("<enumerated-values>");
foreach (var l in File.ReadAllText("layout_schema_enumerations.csv").Replace ("\r\n", "\n").Split ('\n')) {
if (l.Length == 0) continue;
var ad = l.Split (',');
var name = ad [0];
string opt = null;
switch (name [name.Length - 1]) {
case '*':
opt = " else=\"allowed\"";
goto case ' ';
case '^':
opt = " flags=\"true\"";
goto case ' ';
case ' ':
name = name.Substring (0, name.Length - 1);
break;
}
Console.WriteLine (" <attr name=\"{0}\"{1}>", name, opt);
foreach (var item in ad.Skip (1))
if (item.Length > 0)
Console.WriteLine (" <value>{0}</value>", item);
Console.WriteLine (" </attr>");
}
Console.WriteLine ("</enumerated-values>");
}
}