Advertisement
AlvinSeville7cf

Compiler generated code

Apr 14th, 2021
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.62 KB | None | 0 0
  1.  
  2. using System;
  3.  
  4. namespace MoreNET.Utils
  5. {
  6.     public static class BaseType
  7.     {
  8.         public static Byte ReadByte(string prompt = "")
  9.         {
  10.             Console.Write(prompt);
  11.             return Byte.Parse(Console.ReadLine());
  12.         }
  13.  
  14.         public static Byte ReadByte<TException>(Action handler, string prompt = "")
  15.             where TException : Exception
  16.         {
  17.             Console.Write(prompt);
  18.             try
  19.             {
  20.                 return Byte.Parse(Console.ReadLine());
  21.             }
  22.             catch (TException)
  23.             {
  24.                 handler();
  25.                 return default;
  26.             }
  27.         }
  28.  
  29.         public static Byte ReadByte<TException>(Action<string> handler, string prompt = "")
  30.             where TException : Exception
  31.         {
  32.             Console.Write(prompt);
  33.             var input = Console.ReadLine();
  34.             try
  35.             {
  36.                 return Byte.Parse(input);
  37.             }
  38.             catch (TException)
  39.             {
  40.                 handler(input);
  41.                 return default;
  42.             }
  43.         }
  44.  
  45.         public static Byte ReadByte<TException>(Func<Byte> handler, string prompt = "")
  46.             where TException : Exception
  47.         {
  48.             Console.Write(prompt);
  49.             try
  50.             {
  51.                 return Byte.Parse(Console.ReadLine());
  52.             }
  53.             catch (TException)
  54.             {
  55.                 return handler();
  56.             }
  57.         }
  58.  
  59.         public static Byte ReadByte<TException>(Func<string, Byte> handler, string prompt = "")
  60.             where TException : Exception
  61.         {
  62.             Console.Write(prompt);
  63.             var input = Console.ReadLine();
  64.             try
  65.             {
  66.                 return Byte.Parse(input);
  67.             }
  68.             catch (TException)
  69.             {
  70.                 return handler(input);
  71.             }
  72.         }
  73.  
  74.         public static SByte ReadSByte(string prompt = "")
  75.         {
  76.             Console.Write(prompt);
  77.             return SByte.Parse(Console.ReadLine());
  78.         }
  79.  
  80.         public static SByte ReadSByte<TException>(Action handler, string prompt = "")
  81.             where TException : Exception
  82.         {
  83.             Console.Write(prompt);
  84.             try
  85.             {
  86.                 return SByte.Parse(Console.ReadLine());
  87.             }
  88.             catch (TException)
  89.             {
  90.                 handler();
  91.                 return default;
  92.             }
  93.         }
  94.  
  95.         public static SByte ReadSByte<TException>(Action<string> handler, string prompt = "")
  96.             where TException : Exception
  97.         {
  98.             Console.Write(prompt);
  99.             var input = Console.ReadLine();
  100.             try
  101.             {
  102.                 return SByte.Parse(input);
  103.             }
  104.             catch (TException)
  105.             {
  106.                 handler(input);
  107.                 return default;
  108.             }
  109.         }
  110.  
  111.         public static SByte ReadSByte<TException>(Func<SByte> handler, string prompt = "")
  112.             where TException : Exception
  113.         {
  114.             Console.Write(prompt);
  115.             try
  116.             {
  117.                 return SByte.Parse(Console.ReadLine());
  118.             }
  119.             catch (TException)
  120.             {
  121.                 return handler();
  122.             }
  123.         }
  124.  
  125.         public static SByte ReadSByte<TException>(Func<string, SByte> handler, string prompt = "")
  126.             where TException : Exception
  127.         {
  128.             Console.Write(prompt);
  129.             var input = Console.ReadLine();
  130.             try
  131.             {
  132.                 return SByte.Parse(input);
  133.             }
  134.             catch (TException)
  135.             {
  136.                 return handler(input);
  137.             }
  138.         }
  139.  
  140.         public static Int16 ReadInt16(string prompt = "")
  141.         {
  142.             Console.Write(prompt);
  143.             return Int16.Parse(Console.ReadLine());
  144.         }
  145.  
  146.         public static Int16 ReadInt16<TException>(Action handler, string prompt = "")
  147.             where TException : Exception
  148.         {
  149.             Console.Write(prompt);
  150.             try
  151.             {
  152.                 return Int16.Parse(Console.ReadLine());
  153.             }
  154.             catch (TException)
  155.             {
  156.                 handler();
  157.                 return default;
  158.             }
  159.         }
  160.  
  161.         public static Int16 ReadInt16<TException>(Action<string> handler, string prompt = "")
  162.             where TException : Exception
  163.         {
  164.             Console.Write(prompt);
  165.             var input = Console.ReadLine();
  166.             try
  167.             {
  168.                 return Int16.Parse(input);
  169.             }
  170.             catch (TException)
  171.             {
  172.                 handler(input);
  173.                 return default;
  174.             }
  175.         }
  176.  
  177.         public static Int16 ReadInt16<TException>(Func<Int16> handler, string prompt = "")
  178.             where TException : Exception
  179.         {
  180.             Console.Write(prompt);
  181.             try
  182.             {
  183.                 return Int16.Parse(Console.ReadLine());
  184.             }
  185.             catch (TException)
  186.             {
  187.                 return handler();
  188.             }
  189.         }
  190.  
  191.         public static Int16 ReadInt16<TException>(Func<string, Int16> handler, string prompt = "")
  192.             where TException : Exception
  193.         {
  194.             Console.Write(prompt);
  195.             var input = Console.ReadLine();
  196.             try
  197.             {
  198.                 return Int16.Parse(input);
  199.             }
  200.             catch (TException)
  201.             {
  202.                 return handler(input);
  203.             }
  204.         }
  205.  
  206.         public static UInt16 ReadUInt16(string prompt = "")
  207.         {
  208.             Console.Write(prompt);
  209.             return UInt16.Parse(Console.ReadLine());
  210.         }
  211.  
  212.         public static UInt16 ReadUInt16<TException>(Action handler, string prompt = "")
  213.             where TException : Exception
  214.         {
  215.             Console.Write(prompt);
  216.             try
  217.             {
  218.                 return UInt16.Parse(Console.ReadLine());
  219.             }
  220.             catch (TException)
  221.             {
  222.                 handler();
  223.                 return default;
  224.             }
  225.         }
  226.  
  227.         public static UInt16 ReadUInt16<TException>(Action<string> handler, string prompt = "")
  228.             where TException : Exception
  229.         {
  230.             Console.Write(prompt);
  231.             var input = Console.ReadLine();
  232.             try
  233.             {
  234.                 return UInt16.Parse(input);
  235.             }
  236.             catch (TException)
  237.             {
  238.                 handler(input);
  239.                 return default;
  240.             }
  241.         }
  242.  
  243.         public static UInt16 ReadUInt16<TException>(Func<UInt16> handler, string prompt = "")
  244.             where TException : Exception
  245.         {
  246.             Console.Write(prompt);
  247.             try
  248.             {
  249.                 return UInt16.Parse(Console.ReadLine());
  250.             }
  251.             catch (TException)
  252.             {
  253.                 return handler();
  254.             }
  255.         }
  256.  
  257.         public static UInt16 ReadUInt16<TException>(Func<string, UInt16> handler, string prompt = "")
  258.             where TException : Exception
  259.         {
  260.             Console.Write(prompt);
  261.             var input = Console.ReadLine();
  262.             try
  263.             {
  264.                 return UInt16.Parse(input);
  265.             }
  266.             catch (TException)
  267.             {
  268.                 return handler(input);
  269.             }
  270.         }
  271.  
  272.         public static Int32 ReadInt32(string prompt = "")
  273.         {
  274.             Console.Write(prompt);
  275.             return Int32.Parse(Console.ReadLine());
  276.         }
  277.  
  278.         public static Int32 ReadInt32<TException>(Action handler, string prompt = "")
  279.             where TException : Exception
  280.         {
  281.             Console.Write(prompt);
  282.             try
  283.             {
  284.                 return Int32.Parse(Console.ReadLine());
  285.             }
  286.             catch (TException)
  287.             {
  288.                 handler();
  289.                 return default;
  290.             }
  291.         }
  292.  
  293.         public static Int32 ReadInt32<TException>(Action<string> handler, string prompt = "")
  294.             where TException : Exception
  295.         {
  296.             Console.Write(prompt);
  297.             var input = Console.ReadLine();
  298.             try
  299.             {
  300.                 return Int32.Parse(input);
  301.             }
  302.             catch (TException)
  303.             {
  304.                 handler(input);
  305.                 return default;
  306.             }
  307.         }
  308.  
  309.         public static Int32 ReadInt32<TException>(Func<Int32> handler, string prompt = "")
  310.             where TException : Exception
  311.         {
  312.             Console.Write(prompt);
  313.             try
  314.             {
  315.                 return Int32.Parse(Console.ReadLine());
  316.             }
  317.             catch (TException)
  318.             {
  319.                 return handler();
  320.             }
  321.         }
  322.  
  323.         public static Int32 ReadInt32<TException>(Func<string, Int32> handler, string prompt = "")
  324.             where TException : Exception
  325.         {
  326.             Console.Write(prompt);
  327.             var input = Console.ReadLine();
  328.             try
  329.             {
  330.                 return Int32.Parse(input);
  331.             }
  332.             catch (TException)
  333.             {
  334.                 return handler(input);
  335.             }
  336.         }
  337.  
  338.         public static UInt32 ReadUInt32(string prompt = "")
  339.         {
  340.             Console.Write(prompt);
  341.             return UInt32.Parse(Console.ReadLine());
  342.         }
  343.  
  344.         public static UInt32 ReadUInt32<TException>(Action handler, string prompt = "")
  345.             where TException : Exception
  346.         {
  347.             Console.Write(prompt);
  348.             try
  349.             {
  350.                 return UInt32.Parse(Console.ReadLine());
  351.             }
  352.             catch (TException)
  353.             {
  354.                 handler();
  355.                 return default;
  356.             }
  357.         }
  358.  
  359.         public static UInt32 ReadUInt32<TException>(Action<string> handler, string prompt = "")
  360.             where TException : Exception
  361.         {
  362.             Console.Write(prompt);
  363.             var input = Console.ReadLine();
  364.             try
  365.             {
  366.                 return UInt32.Parse(input);
  367.             }
  368.             catch (TException)
  369.             {
  370.                 handler(input);
  371.                 return default;
  372.             }
  373.         }
  374.  
  375.         public static UInt32 ReadUInt32<TException>(Func<UInt32> handler, string prompt = "")
  376.             where TException : Exception
  377.         {
  378.             Console.Write(prompt);
  379.             try
  380.             {
  381.                 return UInt32.Parse(Console.ReadLine());
  382.             }
  383.             catch (TException)
  384.             {
  385.                 return handler();
  386.             }
  387.         }
  388.  
  389.         public static UInt32 ReadUInt32<TException>(Func<string, UInt32> handler, string prompt = "")
  390.             where TException : Exception
  391.         {
  392.             Console.Write(prompt);
  393.             var input = Console.ReadLine();
  394.             try
  395.             {
  396.                 return UInt32.Parse(input);
  397.             }
  398.             catch (TException)
  399.             {
  400.                 return handler(input);
  401.             }
  402.         }
  403.  
  404.         public static Int64 ReadInt64(string prompt = "")
  405.         {
  406.             Console.Write(prompt);
  407.             return Int64.Parse(Console.ReadLine());
  408.         }
  409.  
  410.         public static Int64 ReadInt64<TException>(Action handler, string prompt = "")
  411.             where TException : Exception
  412.         {
  413.             Console.Write(prompt);
  414.             try
  415.             {
  416.                 return Int64.Parse(Console.ReadLine());
  417.             }
  418.             catch (TException)
  419.             {
  420.                 handler();
  421.                 return default;
  422.             }
  423.         }
  424.  
  425.         public static Int64 ReadInt64<TException>(Action<string> handler, string prompt = "")
  426.             where TException : Exception
  427.         {
  428.             Console.Write(prompt);
  429.             var input = Console.ReadLine();
  430.             try
  431.             {
  432.                 return Int64.Parse(input);
  433.             }
  434.             catch (TException)
  435.             {
  436.                 handler(input);
  437.                 return default;
  438.             }
  439.         }
  440.  
  441.         public static Int64 ReadInt64<TException>(Func<Int64> handler, string prompt = "")
  442.             where TException : Exception
  443.         {
  444.             Console.Write(prompt);
  445.             try
  446.             {
  447.                 return Int64.Parse(Console.ReadLine());
  448.             }
  449.             catch (TException)
  450.             {
  451.                 return handler();
  452.             }
  453.         }
  454.  
  455.         public static Int64 ReadInt64<TException>(Func<string, Int64> handler, string prompt = "")
  456.             where TException : Exception
  457.         {
  458.             Console.Write(prompt);
  459.             var input = Console.ReadLine();
  460.             try
  461.             {
  462.                 return Int64.Parse(input);
  463.             }
  464.             catch (TException)
  465.             {
  466.                 return handler(input);
  467.             }
  468.         }
  469.  
  470.         public static UInt64 ReadUInt64(string prompt = "")
  471.         {
  472.             Console.Write(prompt);
  473.             return UInt64.Parse(Console.ReadLine());
  474.         }
  475.  
  476.         public static UInt64 ReadUInt64<TException>(Action handler, string prompt = "")
  477.             where TException : Exception
  478.         {
  479.             Console.Write(prompt);
  480.             try
  481.             {
  482.                 return UInt64.Parse(Console.ReadLine());
  483.             }
  484.             catch (TException)
  485.             {
  486.                 handler();
  487.                 return default;
  488.             }
  489.         }
  490.  
  491.         public static UInt64 ReadUInt64<TException>(Action<string> handler, string prompt = "")
  492.             where TException : Exception
  493.         {
  494.             Console.Write(prompt);
  495.             var input = Console.ReadLine();
  496.             try
  497.             {
  498.                 return UInt64.Parse(input);
  499.             }
  500.             catch (TException)
  501.             {
  502.                 handler(input);
  503.                 return default;
  504.             }
  505.         }
  506.  
  507.         public static UInt64 ReadUInt64<TException>(Func<UInt64> handler, string prompt = "")
  508.             where TException : Exception
  509.         {
  510.             Console.Write(prompt);
  511.             try
  512.             {
  513.                 return UInt64.Parse(Console.ReadLine());
  514.             }
  515.             catch (TException)
  516.             {
  517.                 return handler();
  518.             }
  519.         }
  520.  
  521.         public static UInt64 ReadUInt64<TException>(Func<string, UInt64> handler, string prompt = "")
  522.             where TException : Exception
  523.         {
  524.             Console.Write(prompt);
  525.             var input = Console.ReadLine();
  526.             try
  527.             {
  528.                 return UInt64.Parse(input);
  529.             }
  530.             catch (TException)
  531.             {
  532.                 return handler(input);
  533.             }
  534.         }
  535.  
  536.         public static Char ReadChar(string prompt = "")
  537.         {
  538.             Console.Write(prompt);
  539.             return Console.ReadKey(true).KeyChar;
  540.         }
  541.  
  542.         public static Char ReadChar<TException>(Action handler, string prompt = "")
  543.             where TException : Exception
  544.         {
  545.             Console.Write(prompt);
  546.             return Console.ReadKey(true).KeyChar;
  547.         }
  548.  
  549.         public static Char ReadChar<TException>(Action<string> handler, string prompt = "")
  550.             where TException : Exception
  551.         {
  552.             Console.Write(prompt);
  553.             var input = Console.ReadKey(true).KeyChar;
  554.             return Console.ReadKey(true).KeyChar;
  555.         }
  556.  
  557.         public static Char ReadChar<TException>(Func<Char> handler, string prompt = "")
  558.             where TException : Exception
  559.         {
  560.             Console.Write(prompt);
  561.             return Console.ReadKey(true).KeyChar;
  562.         }
  563.  
  564.         public static Char ReadChar<TException>(Func<string, Char> handler, string prompt = "")
  565.             where TException : Exception
  566.         {
  567.             Console.Write(prompt);
  568.             var input = Console.ReadKey(true).KeyChar;
  569.             return Console.ReadKey(true).KeyChar;
  570.         }
  571.  
  572.         public static String ReadString(string prompt = "")
  573.         {
  574.             Console.Write(prompt);
  575.             return Console.ReadLine();
  576.         }
  577.  
  578.         public static String ReadString<TException>(Action handler, string prompt = "")
  579.             where TException : Exception
  580.         {
  581.             Console.Write(prompt);
  582.             return Console.ReadLine();
  583.         }
  584.  
  585.         public static String ReadString<TException>(Action<string> handler, string prompt = "")
  586.             where TException : Exception
  587.         {
  588.             Console.Write(prompt);
  589.             var input = Console.ReadLine();
  590.             return Console.ReadLine();
  591.         }
  592.  
  593.         public static String ReadString<TException>(Func<String> handler, string prompt = "")
  594.             where TException : Exception
  595.         {
  596.             Console.Write(prompt);
  597.             return Console.ReadLine();
  598.         }
  599.  
  600.         public static String ReadString<TException>(Func<string, String> handler, string prompt = "")
  601.             where TException : Exception
  602.         {
  603.             Console.Write(prompt);
  604.             var input = Console.ReadLine();
  605.             return Console.ReadLine();
  606.         }
  607.     }
  608. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement