This commit is contained in:
2020-02-27 16:20:05 +00:00
parent 1958e3fdde
commit fc604e1745
2 changed files with 7 additions and 2 deletions

View File

@@ -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
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();
string ret = oldName + appendString;
var diff = maxLength - ret.Length;