aboutsummaryrefslogtreecommitdiff
path: root/ErrorResponseCodeGenerator/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ErrorResponseCodeGenerator/Program.cs')
-rw-r--r--ErrorResponseCodeGenerator/Program.cs68
1 files changed, 0 insertions, 68 deletions
diff --git a/ErrorResponseCodeGenerator/Program.cs b/ErrorResponseCodeGenerator/Program.cs
deleted file mode 100644
index 5ea8aaca..00000000
--- a/ErrorResponseCodeGenerator/Program.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Linq;
-using System.Reflection;
-
-namespace ErrorResponseCodeGenerator
-{
- class Program
- {
- static void Main(string[] args)
- {
- var code = "";
-
- void RecursiveAddErrorCode(Type type, bool root)
- {
- code += $@"
- public static class {(root ? "ErrorResponse" : type.Name)}
- {{
-";
-
- foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)
- .Where(fi => fi.IsLiteral && !fi.IsInitOnly && fi.FieldType == typeof(int)))
- {
- var path = type.FullName.Replace("+", ".").Replace("Timeline.Models.Http.ErrorCodes.", "") + "." + field.Name;
-
- code += $@"
- public static CommonResponse {field.Name}(params object?[] formatArgs)
- {{
- return new CommonResponse({"ErrorCodes." + path}, string.Format({path.Replace(".", "_")}, formatArgs));
- }}
-
- public static CommonResponse CustomMessage_{field.Name}(string message, params object?[] formatArgs)
- {{
- return new CommonResponse({"ErrorCodes." + path}, string.Format(message, formatArgs));
- }}
-";
- }
-
- foreach (var nestedType in type.GetNestedTypes())
- {
- RecursiveAddErrorCode(nestedType, false);
- }
-
- code += @"
- }
-";
- }
-
- RecursiveAddErrorCode(typeof(Timeline.Models.Http.ErrorCodes), true);
-
- code = @"
-using static Timeline.Resources.Messages;
-
-namespace Timeline.Models.Http
-{
-$
-}
-".Replace("$", code);
-
- Console.WriteLine(code);
-
- TextCopy.Clipboard.SetText(code);
- var oldColor = Console.ForegroundColor;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Code has copied to clipboard!");
- Console.ForegroundColor = oldColor;
- }
- }
-}