1.0-dev10 (Code cleaning)

This commit is contained in:
2022-03-02 22:13:28 +01:00
Unverified
parent 25041f9d43
commit d8eb103dcc
36 changed files with 338 additions and 336 deletions

View File

@@ -1,38 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VDownload.Core.Services
{
public class TaskId
{
// VARIABLES
#region CONSTANTS
// RANDOM
private static readonly Random Random = new Random();
private static readonly char[] CharsID = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
private static readonly int LengthID = 10;
// ID SETTINGS
private static readonly char[] IDChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
private static readonly int IDLength = 10;
#endregion
#region PROPERTIES
// USED IDS LIST
private static readonly List<string> UsedIDs = new List<string>();
// METHOD
#endregion
#region METHODS
// GET TASK ID
public static string Get()
{
string id;
do
{
id = "";
while (id.Length < LengthID)
while (id.Length < IDLength)
{
id += CharsID[Random.Next(0, CharsID.Length)];
id += IDChars[Random.Next(0, IDChars.Length)];
}
} while (UsedIDs.Contains(id));
UsedIDs.Add(id);
return id;
}
// DISPOSE TASK ID
public static void Dispose(string id)
{
UsedIDs.Remove(id);
}
#endregion
}
}