Class AssetPathProvider
- Namespace
- CSF.Screenplay.Reporting
- Assembly
- CSF.Screenplay.dll
Implementation of IGetsAssetFilePath which filename paths for assets.
public class AssetPathProvider : IGetsAssetFilePath
- Inheritance
-
AssetPathProvider
- Implements
- Inherited Members
Remarks
Paths which are generated by this class are in the format: YYYY-MM-DDTHHMMSSZ_PERFORMANCEID_ASSETNUMBER_BASENAME.
The first part of the filename is a timestamp, similar to ISO 8601, except that the : characters separating
the hours, minutes and seconds are omitted. The second part is the performance identifier, equal to either the
Identifier of the last item from NamingHierarchy, or if the naming
hierarchy is empty, the PerformanceIdentity. The third part is a zero-padded asset number, to
differentiate between multiple assets generated during the same performance. The final part is the base name of the asset
as specified by the consuming logic.
The path returned from GetAssetFilePath(string) will be in the same directory as the report file, as returned by GetReportPath(). If the report path returned by that service is null then this method will also return null, meaning that the asset file should not be written.
This type is somewhat stateful, because it maintains an internal counter in order to provide the asset numbers (described above). It should be consumed from dependency injection as a scoped service, so that each performance has its own instance of this type.
Constructors
AssetPathProvider(IGetsReportPath, IPerformance)
Initializes a new instance of the AssetPathProvider class.
public AssetPathProvider(IGetsReportPath reportPathProvider, IPerformance performance)
Parameters
reportPathProviderIGetsReportPathThe report path provider.
performanceIPerformanceThe performance.
Methods
GetAssetFilePath(string)
Gets the filesystem path to which an asset file should be written.
public string GetAssetFilePath(string baseName)
Parameters
baseNamestringA short & descriptive filename fragment, which includes the file extension but no path information
Returns
- string
An absolute file system path at which the asset file should be saved, or a null reference indicating that the asset file should not be saved.
Remarks
If reporting is disabled, for the same reasons as GetReportPath() would return null, then this method will also return null. In that case, reporting is disabled and no asset files should be written to the file system.
If reporting is enabled, then this method should return an absolute file system path to which an asset file should be written, where the asset has the specified 'base name'. That base name should be a short filename fragment which describes the asset. This file name will be embellished with other information by this method, such as to ensure that the file name is unique within the current Screenplay run.