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
item
IProjectItemItem 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
item
IProjectItemAn IProjectItem with an IProject as root parent.
Returns
- string
The absolute path for the item, including the item name.
Exceptions
- ArgumentNullException
Thrown when
item
is null, the Name ofitem
is null, empty or white space, oritem
implements IProject and Directory is null, empty or white space.- InvalidOperationException
Thrown when
item
doesn't belong to a IProject implementation. This means the root Parent element ofitem
doesn't implement IProject.
GetRootProjectItem(IProjectItem)
Gets the root project item (normally an IProject).
public static IProjectItem GetRootProjectItem(this IProjectItem item)
Parameters
item
IProjectItemA 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
parentItem
IProjectItemProject item as root for the relative path.
relativePath
stringPath to a project item.
item
IProjectItemProject 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.Name
orrelativePath
is null.