C# Class Microsoft.VisualStudio.Project.ProjectElement

This class represent a project item (usualy a file) and allow getting and setting attribute on it. This class allow us to keep the internal details of our items hidden from our derived classes. While the class itself is public so it can be manipulated by derived classes, its internal constructors make sure it can only be created from within the assembly.
Mostra file Open project: tunnelvisionlabs/MPFProj10 Class Usage Examples

Public Methods

Method Description
Equals ( object obj ) : bool
GetEvaluatedMetadata ( string attributeName ) : string
GetFullPathForElement ( ) : string

Return an absolute path for the passed in element. If the element is already an absolute path, it is returned. Otherwise, it is unrelativized using the project directory as the base. Note that any ".." in the paths will be resolved. For non-file system based project, it may make sense to override.

GetHashCode ( ) : int
GetMetadata ( string attributeName ) : string

Get the value of an attribute on a project element

GetMetadataAndThrow ( string attributeName, Exception exception ) : string

Gets the attribute and throws the handed exception if the exception if the attribute is empty or null.

The method will throw an Exception and neglect the passed in exception if the attribute is deleted

ProjectElement ( ProjectNode project, Microsoft.Build.Evaluation existingItem, bool virtualFolder ) : System

Constructor to Wrap an existing MSBuild.ProjectItem Only have internal constructors as the only one who should be creating such object is the project itself (see Project.CreateFileNode()).

ProjectElement ( ProjectNode project, string itemPath, string itemType ) : System

Constructor to create a new MSBuild.ProjectItem and add it to the project Only have internal constructors as the only one who should be creating such object is the project itself (see Project.CreateFileNode()).

RefreshProperties ( ) : void

Reevaluate all properties for the current item This should be call if you believe the property for this item may have changed since it was created/refreshed, or global properties this items depends on have changed. Be aware that there is a perf cost in calling this function.

RemoveFromProjectFile ( ) : void

Calling this method remove this item from the project file. Once the item is delete, you should not longer be using it. Note that the item should be removed from the hierarchy prior to this call.

Rename ( string newPath ) : void
SetMetadata ( string attributeName, string attributeValue ) : void

Set an attribute on the project element

operator ( ) : bool

Method Details

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

GetEvaluatedMetadata() public method

public GetEvaluatedMetadata ( string attributeName ) : string
attributeName string
return string

GetFullPathForElement() public method

Return an absolute path for the passed in element. If the element is already an absolute path, it is returned. Otherwise, it is unrelativized using the project directory as the base. Note that any ".." in the paths will be resolved. For non-file system based project, it may make sense to override.
public GetFullPathForElement ( ) : string
return string

GetHashCode() public method

public GetHashCode ( ) : int
return int

GetMetadata() public method

Get the value of an attribute on a project element
public GetMetadata ( string attributeName ) : string
attributeName string Name of the attribute to get the value for
return string

GetMetadataAndThrow() public method

Gets the attribute and throws the handed exception if the exception if the attribute is empty or null.
The method will throw an Exception and neglect the passed in exception if the attribute is deleted
public GetMetadataAndThrow ( string attributeName, Exception exception ) : string
attributeName string The name of the attribute to get.
exception System.Exception The exception to be thrown if not found or empty.
return string

ProjectElement() public method

Constructor to Wrap an existing MSBuild.ProjectItem Only have internal constructors as the only one who should be creating such object is the project itself (see Project.CreateFileNode()).
public ProjectElement ( ProjectNode project, Microsoft.Build.Evaluation existingItem, bool virtualFolder ) : System
project ProjectNode Project that owns this item
existingItem Microsoft.Build.Evaluation an MSBuild.ProjectItem; can be null if virtualFolder is true
virtualFolder bool Is this item virtual (such as reference folder)
return System

ProjectElement() public method

Constructor to create a new MSBuild.ProjectItem and add it to the project Only have internal constructors as the only one who should be creating such object is the project itself (see Project.CreateFileNode()).
public ProjectElement ( ProjectNode project, string itemPath, string itemType ) : System
project ProjectNode
itemPath string
itemType string
return System

RefreshProperties() public method

Reevaluate all properties for the current item This should be call if you believe the property for this item may have changed since it was created/refreshed, or global properties this items depends on have changed. Be aware that there is a perf cost in calling this function.
public RefreshProperties ( ) : void
return void

RemoveFromProjectFile() public method

Calling this method remove this item from the project file. Once the item is delete, you should not longer be using it. Note that the item should be removed from the hierarchy prior to this call.
public RemoveFromProjectFile ( ) : void
return void

Rename() public method

public Rename ( string newPath ) : void
newPath string
return void

SetMetadata() public method

Set an attribute on the project element
public SetMetadata ( string attributeName, string attributeValue ) : void
attributeName string Name of the attribute to set
attributeValue string Value to give to the attribute. Use null to delete the metadata definition.
return void

operator() public static method

public static operator ( ) : bool
return bool