mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-28 07:11:52 +00:00
Import code from previous AssetBuilder version
This commit is contained in:
15
src/ZoneCodeGenerator/Utils/AlignmentExtension.cs
Normal file
15
src/ZoneCodeGenerator/Utils/AlignmentExtension.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace ZoneCodeGenerator.Utils
|
||||
{
|
||||
static class AlignmentExtension
|
||||
{
|
||||
public static int Align(this int valueToAlign, int alignment)
|
||||
{
|
||||
return (valueToAlign + alignment - 1) / alignment * alignment;
|
||||
}
|
||||
|
||||
public static long Align(this long valueToAlign, long alignment)
|
||||
{
|
||||
return (valueToAlign + alignment - 1) / alignment * alignment;
|
||||
}
|
||||
}
|
||||
}
|
13
src/ZoneCodeGenerator/Utils/KeyValueExtension.cs
Normal file
13
src/ZoneCodeGenerator/Utils/KeyValueExtension.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZoneCodeGenerator.Utils
|
||||
{
|
||||
public static class KeyValueExtension
|
||||
{
|
||||
public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> keyValuePair, out T1 m1, out T2 m2)
|
||||
{
|
||||
m1 = keyValuePair.Key;
|
||||
m2 = keyValuePair.Value;
|
||||
}
|
||||
}
|
||||
}
|
23
src/ZoneCodeGenerator/Utils/RandomName.cs
Normal file
23
src/ZoneCodeGenerator/Utils/RandomName.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace ZoneCodeGenerator.Utils
|
||||
{
|
||||
static class RandomName
|
||||
{
|
||||
private const int NameLen = 32;
|
||||
|
||||
private static readonly Random random = new Random();
|
||||
private static readonly char[] generatorChars = {
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
||||
};
|
||||
|
||||
public static string GenerateName()
|
||||
{
|
||||
var name = "";
|
||||
for (var i = 0; i < NameLen; i++)
|
||||
name += generatorChars[random.Next(generatorChars.Length)];
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user