summaryrefslogtreecommitdiff
path: root/Gestor.Common/Gestor.Common.Helpers/Functions.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Common/Gestor.Common.Helpers/Functions.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Gestor.Common/Gestor.Common.Helpers/Functions.cs')
-rw-r--r--Gestor.Common/Gestor.Common.Helpers/Functions.cs110
1 files changed, 0 insertions, 110 deletions
diff --git a/Gestor.Common/Gestor.Common.Helpers/Functions.cs b/Gestor.Common/Gestor.Common.Helpers/Functions.cs
deleted file mode 100644
index 25ffadf..0000000
--- a/Gestor.Common/Gestor.Common.Helpers/Functions.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using Gestor.Common.Validation;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Runtime.CompilerServices;
-
-namespace Gestor.Common.Helpers
-{
- public class Functions
- {
- public static System.Diagnostics.Stopwatch Stopwatch;
-
- public static DateTime? StartTime;
-
- public Functions()
- {
- }
-
- public static int Compare(string original, string modified)
- {
- if (original == null)
- {
- original = "";
- }
- if (modified == null)
- {
- modified = "";
- }
- string str = original.ToLongNullable().ToString();
- if (!string.IsNullOrWhiteSpace(str))
- {
- original = str;
- }
- str = modified.ToLongNullable().ToString();
- if (!string.IsNullOrWhiteSpace(str))
- {
- modified = str;
- }
- int length = original.Length;
- int num = modified.Length;
- int[,] numArray = new int[length + 1, num + 1];
- for (int i = 0; i <= length; i++)
- {
- numArray[i, 0] = i;
- }
- for (int j = 0; j <= num; j++)
- {
- numArray[0, j] = j;
- }
- for (int k = 1; k <= length; k++)
- {
- for (int l = 1; l <= num; l++)
- {
- int num1 = modified[l - 1] != original[k - 1];
- numArray[k, l] = (new int[] { numArray[k - 1, l] + 1, numArray[k, l - 1] + 1, numArray[k - 1, l - 1] + num1 }).Min();
- if (k > 1 && l > 1 && original[k - 1] == modified[l - 2] && original[k - 2] == modified[l - 1])
- {
- numArray[k, l] = Math.Min(numArray[k, l], numArray[k - 2, l - 2] + num1);
- }
- }
- }
- return numArray[length, num];
- }
-
- public static DateTime GetNetworkTime()
- {
- DateTime value;
- try
- {
- if (!Functions.StartTime.HasValue)
- {
- byte[] numArray = new byte[48];
- numArray[0] = 27;
- IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable<IPAddress>)Dns.GetHostEntry("time.google.com").AddressList).First<IPAddress>((IPAddress a) => a.AddressFamily == AddressFamily.InterNetwork), 123);
- using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
- {
- socket.Connect(pEndPoint);
- socket.ReceiveTimeout = 3000;
- socket.Send(numArray);
- socket.Receive(numArray);
- socket.Close();
- }
- ulong num = (ulong)numArray[40] << 24 | (ulong)numArray[41] << 16 | (ulong)numArray[42] << 8 | (ulong)numArray[43];
- ulong num1 = (ulong)numArray[44] << 24 | (ulong)numArray[45] << 16 | (ulong)numArray[46] << 8 | (ulong)numArray[47];
- ulong num2 = num * (long)1000 + num1 * (long)1000 / 4294967296L;
- DateTime dateTime = new DateTime(1900, 1, 1);
- dateTime = dateTime.AddMilliseconds((double)num2);
- Functions.StartTime = new DateTime?(dateTime.ToLocalTime());
- Functions.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
- value = Functions.StartTime.Value;
- }
- else
- {
- value = Functions.StartTime.Value;
- value = value.AddMilliseconds((double)Functions.Stopwatch.ElapsedMilliseconds);
- }
- }
- catch (Exception exception)
- {
- Functions.StartTime = new DateTime?(DateTime.Now);
- Functions.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
- value = Functions.StartTime.Value;
- }
- return value;
- }
- }
-} \ No newline at end of file