This commit is contained in:
@@ -90,30 +90,30 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Make a unique but duplicate object name of desired length
|
||||
/// (Used by Duplicate object function)
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <param name="maxLength"></param>
|
||||
/// <returns></returns>
|
||||
public static string NameUniquify(string s, int maxLength)
|
||||
{
|
||||
//Unique string
|
||||
string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||
string ret = s + unique;
|
||||
var diff = maxLength - ret.Length;
|
||||
if (diff < 0)
|
||||
{
|
||||
if (unique.Length >= maxLength)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||
}
|
||||
ret = s.Substring(0, Math.Abs(diff)) + unique;
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Make a unique but duplicate object name of desired length
|
||||
// /// (Used by Duplicate object function)
|
||||
// /// </summary>
|
||||
// /// <param name="s"></param>
|
||||
// /// <param name="maxLength"></param>
|
||||
// /// <returns></returns>
|
||||
// public static string NameUniquify(string s, int maxLength)
|
||||
// {
|
||||
// //Unique string
|
||||
// string unique = " - " + DateUtil.SortableShortCurrentDateTimeValue;
|
||||
// string ret = s + unique;
|
||||
// var diff = maxLength - ret.Length;
|
||||
// if (diff < 0)
|
||||
// {
|
||||
// if (unique.Length >= maxLength)
|
||||
// {
|
||||
// throw new System.ArgumentOutOfRangeException("StringUtil::nameUniquify - maxlength> unique value, source field too short for this function?");
|
||||
// }
|
||||
// ret = s.Substring(0, Math.Abs(diff)) + unique;
|
||||
// }
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
|
||||
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
|
||||
|
||||
Reference in New Issue
Block a user