This commit is contained in:
@@ -119,6 +119,11 @@ namespace AyaNova.Util
|
|||||||
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
||||||
public static string UniqueNameBuilder(string oldName, long appendValue, int maxLength)
|
public static string UniqueNameBuilder(string oldName, long appendValue, int maxLength)
|
||||||
{
|
{
|
||||||
|
//deadman switch
|
||||||
|
if (appendValue > int.MaxValue)
|
||||||
|
{
|
||||||
|
throw new System.OverflowException($"UniqueNameBuilder: Unique name could not be generated for item \"{oldName}\" after {int.MaxValue.ToString()} attempts");
|
||||||
|
}
|
||||||
var appendString = "-" + appendValue.ToString();
|
var appendString = "-" + appendValue.ToString();
|
||||||
string ret = oldName + appendString;
|
string ret = oldName + appendString;
|
||||||
var diff = maxLength - ret.Length;
|
var diff = maxLength - ret.Length;
|
||||||
|
|||||||
Reference in New Issue
Block a user