Added Random.NextString
Rename IQueryCreator to IQueryBuilder
This commit is contained in:
parent
9d4e2d6d9b
commit
3e045d51bf
5 changed files with 82 additions and 31 deletions
31
TShockAPI/Extensions/RandomExt.cs
Normal file
31
TShockAPI/Extensions/RandomExt.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TShockAPI.Extensions
|
||||
{
|
||||
public static class RandomExt
|
||||
{
|
||||
public static string NextString(this Random rand, int length)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
switch (rand.Next(0, 3))
|
||||
{
|
||||
case 0:
|
||||
sb.Append((char)rand.Next('a', 'z' + 1));
|
||||
break;
|
||||
case 1:
|
||||
sb.Append((char)rand.Next('A', 'Z' + 1));
|
||||
break;
|
||||
case 2:
|
||||
sb.Append((char)rand.Next('0', '9' + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue