This commit is contained in:
@@ -270,6 +270,24 @@ namespace AyaNova.PlugIn.V8
|
||||
|
||||
#region Misc utils
|
||||
|
||||
//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;
|
||||
if (diff < 0)
|
||||
{
|
||||
ret = oldName.Substring(0, Math.Abs(diff)) + appendString;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//used to set nonsense values from imported user login and password
|
||||
//just in case they are set active after import but never have their passwords set
|
||||
//so they can't be as easily hacked into
|
||||
@@ -492,6 +510,9 @@ namespace AyaNova.PlugIn.V8
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}//eoc
|
||||
|
||||
Reference in New Issue
Block a user