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.
Afficher le fichier Open project: tunnelvisionlabs/MPFProj10 Class Usage Examples

Méthodes publiques

Méthode 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 méthode

public Equals ( object obj ) : bool
obj object
Résultat bool

GetEvaluatedMetadata() public méthode

public GetEvaluatedMetadata ( string attributeName ) : string
attributeName string
Résultat string

GetFullPathForElement() public méthode

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
Résultat string

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int

GetMetadata() public méthode

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
Résultat string

GetMetadataAndThrow() public méthode

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.
Résultat string

ProjectElement() public méthode

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)
Résultat System

ProjectElement() public méthode

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
Résultat System

RefreshProperties() public méthode

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
Résultat void

RemoveFromProjectFile() public méthode

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
Résultat void

Rename() public méthode

public Rename ( string newPath ) : void
newPath string
Résultat void

SetMetadata() public méthode

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.
Résultat void

operator() public static méthode

public static operator ( ) : bool
Résultat bool