Engines/FlatRedBallXNA/FlatRedBall/Utilities/StringFunctions.cs
/// <summary>
/// Makes an INameable's name unique given a list of existing INameables.
/// </summary>
/// <typeparam name="T">The type of nameable.</typeparam>
/// <typeparam name="U">The type of IList, where the type is an INameable</typeparam>
/// <param name="nameable">The instance to modify if necessary.</param>
/// <param name="list">The list of INameables</param>
Makes an INameable's name unique given a list of existing INameables.
Makes an INameable ' s name unique given a list of existing INameables .
public static void MakeNameUnique<T, U>(T nameable, IList<U> list) where T : INameable where U : INameable
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (((object)nameable) != ((object)list[i]) && 
                    (nameable.Name == list[i].Name || 
                     (string.IsNullOrEmpty(nameable.Name) && string.IsNullOrEmpty(list[i].Name)))
                    )
                {
                    nameable.Name = IncrementNumberAtEnd(nameable.Name);
                    i = -1;
                }
            }
        }
public static void MakeNameUnique < T , U > ( T nameable , IList < U > list ) where T : INameable where U : INameable { for ( int i = 0 ; i < list . Count ; i ++ ) { if ( ( ( object ) nameable ) != ( ( object ) list [ i ] ) && ( nameable . Name == list [ i ] . Name || ( string . IsNullOrEmpty ( nameable . Name ) && string . IsNullOrEmpty ( list [ i ] . Name ) ) ) ) { nameable . Name = IncrementNumberAtEnd ( nameable . Name ) ; i = - 1 ; } } }
Makes an INameable's name unique given a list of existing INameables.
Makes an INameable ' s name unique given a list of existing INameables .
// the name matches an item in the list that isn't the same reference, so increment the number. // restart the loop:
nameable
T
The instance to modify if necessary.
The instance to modify if necessary .
list
IList<U>
The list of INameables
The list of INameables
typeparam
The type of nameable.
The type of nameable .
typeparam
The type of IList, where the type is an INameable
The type of IList where the type is an INameable