4 using System.Collections.Generic;
24 public static string GetUnusedName(
this Session session,
string baseName,
int excludedUserId =
int.MaxValue)
26 List<string> nameList =
new List<string>();
27 return GetUnusedName(session, baseName, excludedUserId, nameList);
43 public static string GetUnusedName(
this Session session,
string baseName,
int excludedUserId, List<string> cachedList)
49 using (var user = session.
GetUser(i))
50 using (var userName = user.GetName())
52 string userNameString = userName.GetString();
53 if (user.GetID() != excludedUserId && userNameString.StartsWith(baseName))
55 cachedList.Add(userNameString);
63 string currentName = baseName;
64 while (cachedList.Contains(currentName))
66 currentName = baseName + (++counter);