Files
EnvelopeGenerator/EnvelopeGenerator.Server/EnvelopeGenerator.Server.Client/Data/DeterministicRandom.cs
TekH 106e62a912 Refactor namespaces to EnvelopeGenerator.Server
Renamed namespaces and related identifiers from EnvelopeGenerator.WebUI
to EnvelopeGenerator.Server across the project. This change affects
data models, services, controllers, and configuration files to ensure
consistency with the new architecture.

Updated @using directives in Razor components and other files to
reflect the new namespace structure. Adjusted project references in
EnvelopeGenerator.Server.csproj to point to the new
EnvelopeGenerator.Server.Client project.

Modified middleware and logging configurations to use the new
EnvelopeGenerator.Server namespace, including changes in Program.cs
and appsettings.json.

Updated resource and file references to use the new
EnvelopeGenerator.Server path, ensuring correct resource loading.

Adjusted configuration options in Program.cs to use the new namespace
for options classes, such as ApiOptions and PdfViewerOptions.

Updated authentication scheme names and related constants to align
with the new namespace structure.

Revised comments and documentation to reflect the new namespace,
ensuring clarity and consistency in the codebase.
2026-06-22 16:14:11 +02:00

61 lines
2.0 KiB
C#

namespace EnvelopeGenerator.Server.Client.Data {
class DeterministicRandom {
const int randomCount = 10000;
static readonly int[] deterministicRandomNumbers;
static readonly DateTime time;
int rnd;
int Next {
get {
rnd = deterministicRandomNumbers[rnd % randomCount];
return rnd;
}
}
public char RandomChar {
get {
return (char)((int)'A' + Random(0, 26));
}
}
public int[] RandomList(int count, int to) {
int[] res = new int[count];
for(int i = 0; i < Math.Min(count, to); i++)
res[i] = i;
for(int i = to; i < count; i++)
res[i] = Random(to);
for(int i = 0; i < count; i++) {
int ind = Random(count);
int temp = res[ind];
res[ind] = res[i];
res[i] = temp;
}
return res;
}
public int Random(int to) {
return Random(0, to);
}
public int Random(int from, int to) {
return Next % Math.Max(1, to - from) + from;
}
public T GetRandomItem<T>(IList<T> list) {
return list[Next % list.Count];
}
public DateTime RandomTime() {
return RandomTime(time, 0, 30 * 24);
}
public DateTime RandomTime(DateTime from, int fromHours, int toHours) {
return from.AddHours(Next % (toHours - fromHours) + fromHours);
}
static DeterministicRandom() {
time = DateTime.Now.AddDays(-62);
Random currentRandom = new Random(randomCount);
deterministicRandomNumbers = new int[randomCount];
for(int i = 0; i < randomCount; i++)
deterministicRandomNumbers[i] = currentRandom.Next(randomCount);
}
public DeterministicRandom(int i) {
this.rnd = i + (i >> 10) + (i >> 20);
}
}
}