Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Too few arguments.");
                return;
            }
            var files = Directory.GetFiles(args[0], "*.txt");

            if (files.Length < 1)
            {
                Console.WriteLine("Not found files.");
                return;
            }
            var configText = File.ReadAllText(Directory.GetFiles(args[0], "namespaces.cfg")[0]);

            Console.WriteLine("Generated files:");
            string[] relativeNamesEnum          = new string[files.Length];
            string[] relativeNamesEnumConverter = new string[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                EnumGenerator generator                     = new EnumGenerator(File.ReadAllText(files[i]), configText);
                string        enumText                      = generator.GetEnumText();
                string        enumConverterText             = generator.GetEnumStringConverterText(true);
                string        fileRelativeNameEnum          = $"Domain\\Enums\\{generator.NameOfEnum}.cs";
                string        fileRelativeNameEnumConverter = $"Domain\\EnumStrings\\{generator.NameOfEnum}Strings.cs";
                string        fileFullNameEnum              = args[1] + "\\" + fileRelativeNameEnum;
                string        fileFullNameEnumConverter     = args[1] + "\\" + fileRelativeNameEnumConverter;
                File.WriteAllText(fileFullNameEnum, enumText);
                Console.WriteLine(fileFullNameEnum);
                File.WriteAllText(fileFullNameEnumConverter, enumConverterText);
                Console.WriteLine(fileFullNameEnumConverter);
                relativeNamesEnum[i]          = fileRelativeNameEnum;
                relativeNamesEnumConverter[i] = fileRelativeNameEnumConverter;
            }
            WriteToCsproj(relativeNamesEnum, relativeNamesEnumConverter, args[1]);
#if DEBUG
            Console.ReadKey();
#endif
        }