Class IProjectItemExtensions
- Namespace
- Loehnert.Lisrt.Scripting.ProjectItem.Project
- Assembly
- Loehnert.Lisrt.Scripting.dll
Provides extensions for the IProjectItem interface.
public static class IProjectItemExtensions
- Inheritance
-
IProjectItemExtensions
- Inherited Members
Methods
GetAllProjectItems(IProjectItem)
Gets all descendants project items. Includes itself.
public static IEnumerable<IProjectItem> GetAllProjectItems(this IProjectItem item)
Parameters
itemIProjectItemItem with sub items.
Returns
- IEnumerable<IProjectItem>
All sub project items and itself or just itself if it isn't an ICompositeProjectItem.
Remarks
Uses ICompositeProjectItem interface to get sub items.
GetFullPath(IProjectItem)
Gets the absolute path of a IProjectItem implantation.
public static string GetFullPath(this IProjectItem item)
Parameters
itemIProjectItemAn IProjectItem with an IProject as root parent.
Returns
- string
The absolute path for the item, including the item name.
Exceptions
- ArgumentNullException
Thrown when
itemis null, the Name ofitemis null, empty or white space, oritemimplements IProject and Directory is null, empty or white space.- InvalidOperationException
Thrown when
itemdoesn't belong to a IProject implementation. This means the root Parent element ofitemdoesn't implement IProject.
GetRootProjectItem(IProjectItem)
Gets the root project item (normally an IProject).
public static IProjectItem GetRootProjectItem(this IProjectItem item)
Parameters
itemIProjectItemA child project item.
Returns
- IProjectItem
The root project item.
TryGetProjectItem(IProjectItem, string, out IProjectItem)
Tries to get the sub project item by relative path.
public static bool TryGetProjectItem(this IProjectItem parentItem, string relativePath, out IProjectItem item)
Parameters
parentItemIProjectItemProject item as root for the relative path.
relativePathstringPath to a project item.
itemIProjectItemProject item from the relative path.
Returns
- bool
True, if relative path was found. Otherwise false.
Remarks
A path could be 'Folder\TextFile.txt' DirectorySeparatorChar or Empty as relative path returns the item itself.
Exceptions
- ArgumentNullException
Thrown when
parentItem,parentItem.Name.NameorrelativePathis null.