Skip to content

Instantly share code, notes, and snippets.

@Traderain
Created August 14, 2017 14:39
Show Gist options
  • Save Traderain/632dcd9609a307f9f5f088bf0de38f45 to your computer and use it in GitHub Desktop.
Save Traderain/632dcd9609a307f9f5f088bf0de38f45 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Dictionary<Tuple<string, int,int, int>, Dictionary<string, int>> Enums = new Dictionary<Tuple<string, int, int, int>, Dictionary<string, int>>();
var top = false;
Tuple<string, int, int, int> tup = null;
var values = new Dictionary<string, int>();
foreach (var line in File.ReadAllLines("global_enums_log.txt"))
{
if(line.StartsWith(" "))
{
var s = line.Trim().Split(' ');
values.Add(string.Join("",s.Take(s.Length-1).ToArray()), int.Parse(s[s.Length-1]));
}
else
{
if(tup != null)
{
Enums.Add(tup, values);
}
var split = line.Trim().Split(' ');
tup = new Tuple<string, int, int, int>(split[0], int.Parse(split[1]), int.Parse(split[2]), int.Parse(split[3]));
values = new Dictionary<string, int>();
}
}
File.Delete("enum.cs");
foreach (var e in Enums)
{
if(e.Value.Count > 0)
{
File.AppendAllLines("enums.cs", new[] { "public enum " + e.Key.Item1, "{" });
File.AppendAllLines("enums.cs", e.Value.Take(e.Value.Count - 1).Select(x => "\t" + x.Key + ","));
File.AppendAllLines("enums.cs", new[] { "\t" + e.Value.Last().Key, "}" });
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment