Table of Contents

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 IProjectItem

Item 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 IProjectItem

An 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 of item is null, empty or white space, or item 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 of item doesn't implement IProject.

GetRootProjectItem(IProjectItem)

Gets the root project item (normally an IProject).

public static IProjectItem GetRootProjectItem(this IProjectItem item)

Parameters

item IProjectItem

A 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 IProjectItem

Project item as root for the relative path.

relativePath string

Path to a project item.

item IProjectItem

Project 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 or relativePath is null.