public static string GetUniqueNameIgnoringProjectItem(this ProjectItems items, ProjectItem itemToIgnore, string itemName, string extension)
 {
     return(NameGenerator.GenerateUniqueName(itemName, extension, n =>
     {
         var foundItem = items.FindItem(n, StringComparer.OrdinalIgnoreCase);
         return foundItem == null ||
         foundItem == itemToIgnore;
     }));
 }
Beispiel #2
0
 public static string GetUniqueName(
     this ProjectItems items,
     string itemName,
     string extension
     ) =>
 NameGenerator.GenerateUniqueName(
     itemName,
     extension,
     n => items.FindItem(n, StringComparer.OrdinalIgnoreCase) == null
     );
Beispiel #3
0
        private static ProjectItem CreateFolder(ProjectItems currentItems, string container)
        {
            var folderName = container;
            int index = 1;

            // Keep looking for a unique name as long as we collide with some item.

            // NOTE(cyrusn): There shouldn't be a race condition here.  While it looks like a rogue
            // component could stomp on the name we've found once we've decided on it, they really
            // can't since we're running on the main thread.  And, if someone does stomp on us
            // somehow, then we really should just throw in that case.
            while (currentItems.FindItem(folderName, StringComparer.OrdinalIgnoreCase) != null)
            {
                folderName = container + index;
                index++;
            }

            return currentItems.AddFolder(folderName);
        }
Beispiel #4
0
        private static ProjectItem CreateFolder(ProjectItems currentItems, string container)
        {
            var folderName = container;
            var index      = 1;

            // Keep looking for a unique name as long as we collide with some item.

            // NOTE(cyrusn): There shouldn't be a race condition here.  While it looks like a rogue
            // component could stomp on the name we've found once we've decided on it, they really
            // can't since we're running on the main thread.  And, if someone does stomp on us
            // somehow, then we really should just throw in that case.
            while (currentItems.FindItem(folderName, StringComparer.OrdinalIgnoreCase) != null)
            {
                folderName = container + index;
                index++;
            }

            return(currentItems.AddFolder(folderName));
        }
        public static ProjectItem FindFolder(this ProjectItems items, string folderName)
        {
            var item = items.FindItem(folderName, StringComparer.OrdinalIgnoreCase);

            return(item.IsFolder() ? item : null);
        }