private static void LongToUpperHexStringIdGenerator() { Debug.Log(" == String ids (upper hex conversion) with prefix 'upper' =="); var idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), IdStringGeneratorWrapper.UpperHex, "upper"); foreach (var id in idGenerator.Take(5).ToArray()) { Debug.Log(id); } }
public void LongToStringIdGeneratorTest() { _output.WriteLine(" == String ids with prefix 'o' =="); var idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), "Pro_"); foreach (var id in idGenerator.Take(5).ToArray()) { _output.WriteLine(id); } }
private static void LongToStringIdGenerator() { Console.WriteLine(); Console.WriteLine(" == String ids with prefix 'o' =="); var idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), "o"); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } }
public void VerifyBase32WithLeadingZero() { var generator = new IdStringGeneratorWrapper( new FakeIdGenerator(0L, 1L, 10L, 63L, 64L, 0x7FFFFFFFFFFFFFFFL), IdStringGeneratorWrapper.Base32LeadingZero); Assert.AreEqual("0000000000000", generator.GenerateId()); Assert.AreEqual("0000000000001", generator.GenerateId()); Assert.AreEqual("000000000000A", generator.GenerateId()); Assert.AreEqual("000000000001V", generator.GenerateId()); Assert.AreEqual("0000000000020", generator.GenerateId()); Assert.AreEqual("7VVVVVVVVVVVV", generator.GenerateId()); }
public void VerifyBase32() { var generator = new IdStringGeneratorWrapper( new FakeIdGenerator(0L, 1L, 10L, 63L, 64L, 0x7FFFFFFFFFFFFFFFL), IdStringGeneratorWrapper.Base32); Assert.AreEqual("0", generator.GenerateId()); Assert.AreEqual("1", generator.GenerateId()); Assert.AreEqual("A", generator.GenerateId()); Assert.AreEqual("1V", generator.GenerateId()); Assert.AreEqual("20", generator.GenerateId()); Assert.AreEqual("7VVVVVVVVVVVV", generator.GenerateId()); }
public void LongToBase32StringIdGenerator() { _output.WriteLine(" == String ids (base 32 conversion) =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.Base32); foreach (var id in idGenerator.Take(50).ToArray()) { _output.WriteLine(id); } }
public void LongToUpperHexStringIdGenerator() { _output.WriteLine(" == String ids (upper hex conversion) with prefix 'upper' =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.UpperHex, "upper"); foreach (var id in idGenerator.Take(5).ToArray()) { _output.WriteLine(id); } }
private static void LongToLowerHexStringIdGenerator() { Console.WriteLine(); Console.WriteLine(" == String ids (lower hex conversion) with prefix 'low' =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.LowerHex, "low"); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } }
public static void SetMachineId(short machineId) { MachineId = machineId; // 마스크 Index 순서 바꾸지 말것!! _id64GeneratorAccountDBKey = new Id64Generator(machineId, 0, GenCustomMask(1)); _id64GeneratorEZBotDBKey = new Id64Generator(machineId, 0, GenCustomMask(2)); _id64GeneratorExchangeDBKey = new Id64Generator(machineId, 0, GenCustomMask(3)); _id64GeneratorTransactionDBKey = new Id64Generator(machineId, 0, GenCustomMask(4)); _idGeneratorVerifyCode = new IdStringGeneratorWrapper(new Id64Generator(machineId, 0, 0xb25e3f91), IdStringGeneratorWrapper.Base32, "V"); _idGeneratorActivationCode = new IdStringGeneratorWrapper(new Id64Generator(machineId, 0, 0xb25e3f91), IdStringGeneratorWrapper.Base32, "A"); _idGeneratorAccessToken = new IdStringGeneratorWrapper(new Id64Generator(machineId, 0, 0xb25e3f91), IdStringGeneratorWrapper.Base32, "AT"); }
// Start is called before the first frame update private void Start() { Debug.Log(Id); const int count = 1; var unique = new Id64Generator(10); var unique2 = new IdGuidGenerator(10); var unique3 = new IdStringGeneratorWrapper(unique); Profiler.BeginSample("track snowflake 1"); string str1 = ""; for (int i = 0; i < count; i++) { str1 = unique.GenerateId().ToString(); } Profiler.EndSample(); Profiler.BeginSample("track snowflake 2"); for (int i = 0; i < count; i++) { unique2.GenerateId(); } Profiler.EndSample(); Profiler.BeginSample("track snowflake 3"); string str2 = ""; for (int i = 0; i < count; i++) { str2 = unique3.GenerateId(); } Profiler.EndSample(); Profiler.BeginSample("track guid"); for (int i = 0; i < count; i++) { Guid.NewGuid(); } Profiler.EndSample(); Debug.Log(str1); Debug.Log(str2); Main(); }
private static void LongToBase32StringIdGenerator() { Debug.Log(" == String ids (base 32 conversion) =="); var idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), IdStringGeneratorWrapper.Base32); foreach (var id in idGenerator.Take(5).ToArray()) { Debug.Log(id); } Debug.Log(" == String ids (base 32 conversion, leading zero) =="); idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), IdStringGeneratorWrapper.Base32LeadingZero); foreach (var id in idGenerator.Take(5).ToArray()) { Debug.Log(id); } }
public void LongToLowerHexStringIdGenerator() { _output.WriteLine(" == String ids (lower hex conversion) with prefix 'low' =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.LowerHex, "low"); foreach (var id in idGenerator.Take(5).ToArray()) { _output.WriteLine(id); } int a = 0, b = 0; for (int i = 0; i < 20; i++) { _output.WriteLine(GetLongLowerString(a, b)); a++; b++; } }
public static bool SetMachineId(short machineId) { if (IsValidMachineId(machineId) == false) { return(false); } MachineId = machineId; // 마스크 Index 순서 바꾸지 말것!! _id64Gen_UserId = new Id64Generator(machineId, 0, GenCustomMask(1)); _id64Gen_AppId = new Id64Generator(machineId, 0, GenCustomMask(2)); _id64Gen_AdUnitId = new Id64Generator(machineId, 0, GenCustomMask(3)); _id64Gen_CampaignId = new Id64Generator(machineId, 0, GenCustomMask(4)); _id64Gen_AdDesignId = new Id64Generator(machineId, 0, GenCustomMask(5)); _id64Gen_AdResourceId = new Id64Generator(machineId, 0, GenCustomMask(6)); _id64Gen_AdHistoryId = new Id64Generator(machineId, 0, GenCustomMask(7)); _id64Gen_MiningHistoryId = new Id64Generator(machineId, 0, GenCustomMask(8)); _idGen_VerifyCode = new IdStringGeneratorWrapper(new Id64Generator(machineId, 0, GenCustomMask(5)), IdStringGeneratorWrapper.Base32, "V"); return(true); }
private static void LongToBase32StringIdGenerator() { Console.WriteLine(); Console.WriteLine(" == String ids (base 32 conversion) =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.Base32); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } Console.WriteLine(); Console.WriteLine(" == String ids (base 32 conversion, leading zero) =="); idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.Base32LeadingZero); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } }
private static void LongToUpperHexStringIdGenerator() { Console.WriteLine(); Console.WriteLine(" == String ids (upper hex conversion) with prefix 'upper' =="); var idGenerator = new IdStringGeneratorWrapper( new Id64Generator(), IdStringGeneratorWrapper.UpperHex, "upper"); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } }
private static void LongToStringIdGenerator() { Console.WriteLine(); Console.WriteLine(" == String ids with prefix 'o' =="); var idGenerator = new IdStringGeneratorWrapper(new Id64Generator(), "o"); foreach (var id in idGenerator.Take(5).ToArray()) { Console.WriteLine(id); } }
public void VerifyToStringDefaul() { var generator = new IdStringGeneratorWrapper(new FakeIdGenerator(5416969582936064L)); Assert.AreEqual("5416969582936064", generator.GenerateId()); }
public void VerifyToStringDefaulWithPrefix() { var generator = new IdStringGeneratorWrapper(new FakeIdGenerator(5416969582936001L), "x"); Assert.AreEqual("x5416969582936001", generator.GenerateId()); }