using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rg
{
    class Program
    {
        static void Main(string[] args)
        {
            var current = Directory.GetCurrentDirectory();
            var proj = Directory.GetParent(current).Parent;
            var projDirs = proj.GetDirectories();
            var resDir = projDirs.FirstOrDefault(x => x.Name == "Resources");
            if (resDir == null)
                throw new DirectoryNotFoundException($"Directory \"Resources\" not found in current folder: \"{proj.FullName}\"");
            Directory.SetCurrentDirectory(resDir.FullName);
            using (var stream = File.Create("ResourceConst.cs"))
            using (var writer = new StreamWriter(stream))
            {
                writer.Write(
$@"namespace {proj.Name}
{{
    public static class Resources
    {{
");

                var subDirs = resDir.GetDirectories();
                foreach (var subDir in subDirs)
                {
                    writer.Write(
$@"        public static class {subDir.Name}
        {{
");

                    var files = subDir.GetFiles();
                    foreach (var file in files)
                    {
                        var constName = file.Name.Split('.').First();
                        writer.Write(
$@"            public const string {constName} = ""{file.Name}"";
");
                    }




                    writer.Write(
$@"        }}
");

                }
                writer.Write(
$@"    }}
}}");
            }
        }
    }
}