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

            //LocalizationManager.SetLocalizationMessages(1);
            //Console.WriteLine(LocalizationManager.GetMessage(0));

            //Console.ReadLine();
        }
Ejemplo n.º 2
0
        private void GenerateAllEnumFile_()
        {
            DirectoryInfo directory_info = new DirectoryInfo("./");

            FileInfo[] file_info_array = directory_info.GetFiles(string.Format("*{0}", file_extention));
            //File_info_array.OrderBy(f => f.Name); Should not linq
            SortFileInfo(ref file_info_array);

            List <string>     line_list = new List <string>();
            EnumFileGenerator file_gen  = EnumFileGenerator.Instance;

            int enum_index             = 0;
            int file_info_array_length = file_info_array.Length;

            if (file_info_array_length == 0)
            {
                Console.WriteLine(not_found_file_message); return;
            }

            for (int file_index = 0; file_index < file_info_array.Length; ++file_index)
            {
                FileInfo file_info = file_info_array[file_index];
                string   file_name = file_info.Name.TrimEnd(file_extention.ToCharArray());

                using (TextReader tr = file_info.OpenText())
                {
                    string line;
                    while (!string.IsNullOrEmpty(line = tr.ReadLine()))
                    {
                        line_list.Add(line);
                    }
                }
                int      list_count = line_list.Count;
                string[] key_name   = null;
                string[] value_name = null;
                if (file_name.Equals(key_file_name))
                {
                    var parts = line_list[0].Split(',');
                    key_name = new string[parts.Length - 1];
                    for (int j = 1; j < parts.Length; ++j)
                    {
                        key_name[j - 1] = parts[j];
                    }
                    file_gen.CreateEnumFile(file_name, key_name, value_name, 0);
                }
                else
                {
                    key_name   = new string[list_count];
                    value_name = new string[list_count];
                    for (int i = 0; i < list_count; ++i)
                    {
                        var parts = line_list[i].Split(',');
                        key_name[i]   = parts[0];
                        value_name[i] = parts[1];
                    }
                    file_gen.CreateEnumFile(file_name, key_name, value_name, enum_index * key_name.Length);
                    ++enum_index;
                }

                line_list.Clear();

                Console.WriteLine(complete_message_format, file_index, file_name);
            }
        }