fix: some build & linter warnings

This commit is contained in:
ZavaruKitsu
2022-10-08 19:15:51 +03:00
parent 3f0d109fe2
commit a731e2a8d0
159 changed files with 2738 additions and 3742 deletions
+1 -8
View File
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace TelegramBotBase.Tools
{
@@ -13,7 +6,7 @@ namespace TelegramBotBase.Tools
{
public static T[] Shift<T>(T[] array, int positions)
{
T[] copy = new T[array.Length];
var copy = new T[array.Length];
Array.Copy(array, 0, copy, array.Length - positions, positions);
Array.Copy(array, positions, copy, 0, array.Length - positions);
return copy;
+18 -18
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace TelegramBotBase.Tools
{
@@ -11,17 +10,18 @@ namespace TelegramBotBase.Tools
private static extern bool SetConsoleCtrlHandler(EventHandler handler, bool add);
private delegate bool EventHandler(CtrlType sig);
static EventHandler _handler;
static List<Action> Actions = new List<Action>();
private static EventHandler __handler;
enum CtrlType
private static List<Action> __actions = new List<Action>();
private enum CtrlType
{
CTRL_C_EVENT = 0,
CTRL_BREAK_EVENT = 1,
CTRL_CLOSE_EVENT = 2,
CTRL_LOGOFF_EVENT = 5,
CTRL_SHUTDOWN_EVENT = 6
CtrlCEvent = 0,
CtrlBreakEvent = 1,
CtrlCloseEvent = 2,
CtrlLogoffEvent = 5,
CtrlShutdownEvent = 6
}
static Console()
@@ -31,25 +31,25 @@ namespace TelegramBotBase.Tools
public static void SetHandler(Action action)
{
Actions.Add(action);
__actions.Add(action);
if (_handler != null)
if (__handler != null)
return;
_handler += new EventHandler(Handler);
SetConsoleCtrlHandler(_handler, true);
__handler += Handler;
SetConsoleCtrlHandler(__handler, true);
}
private static bool Handler(CtrlType sig)
{
switch (sig)
{
case CtrlType.CTRL_C_EVENT:
case CtrlType.CTRL_LOGOFF_EVENT:
case CtrlType.CTRL_SHUTDOWN_EVENT:
case CtrlType.CTRL_CLOSE_EVENT:
case CtrlType.CtrlCEvent:
case CtrlType.CtrlLogoffEvent:
case CtrlType.CtrlShutdownEvent:
case CtrlType.CtrlCloseEvent:
foreach (var a in Actions)
foreach (var a in __actions)
{
a();
}
+6 -9
View File
@@ -1,19 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
using TelegramBotBase.Form;
namespace TelegramBotBase.Tools
{
public static class Conversion
{
public static void CustomConversionChecks(FormBase form, KeyValuePair<string, object> p, System.Reflection.PropertyInfo f)
public static void CustomConversionChecks(FormBase form, KeyValuePair<string, object> p, PropertyInfo f)
{
//Newtonsoft Int64/Int32 converter issue
if (f.PropertyType == typeof(Int32))
if (f.PropertyType == typeof(int))
{
int i = 0;
if (int.TryParse(p.Value.ToString(), out i))
if (int.TryParse(p.Value.ToString(), out var i))
{
f.SetValue(form, i);
}
@@ -21,14 +19,13 @@ namespace TelegramBotBase.Tools
}
//Newtonsoft Double/Decimal converter issue
if (f.PropertyType == typeof(Decimal) | f.PropertyType == typeof(Nullable<Decimal>))
if (f.PropertyType == typeof(decimal) | f.PropertyType == typeof(decimal?))
{
decimal d = 0;
if (decimal.TryParse(p.Value.ToString(), out d))
{
f.SetValue(form, d);
}
return;
}
+1 -5
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TelegramBotBase.Tools
{
@@ -25,7 +21,7 @@ namespace TelegramBotBase.Tools
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
{
int diff = dt.DayOfWeek - startOfWeek;
var diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;