1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Text.Json;
- using System.Text.RegularExpressions;
- namespace HelloWorld;
- class Program
- {
- static string[] EXTS = { ".txt", ".json",};
- static string PATTERN = "\'(.+)\':";
- static string IDPATTERN = "ObjectId\\(\"(.+)\"\\)";
- static void Main(string[] args)
- {
- int idx = 0;
- foreach (var item in args)
- {
- Console.WriteLine($"{idx} - {item}");
- if (File.Exists(item)) {
- string ext = Path.GetExtension(item);
- if (EXTS.Contains(ext)) {
- string content = File.ReadAllText(item);
- content = Regex.Replace(content, PATTERN, "\"$1\":");
- content = Regex.Replace(content, IDPATTERN, "\"$1\"");
- if (content != null) {
- WrapperInfo? wrapper = JsonSerializer.Deserialize<WrapperInfo>(content);
- if (wrapper != null) {
- if (wrapper.Cn != null && wrapper.Cn.Length > 0) {
- wrapper.Cn = StringExtension.Decompress(wrapper.Cn);
- }
- if (wrapper.En != null && wrapper.En.Length > 0) {
- wrapper.En = StringExtension.Decompress(wrapper.En);
- }
- Console.WriteLine(wrapper.Cn);
- Console.WriteLine(wrapper.En);
- }
- }
- }
- }
- idx++;
- }
- Console.WriteLine("Press any key...");
- Console.ReadLine();
- }
- }
|