Wiki

Clone wiki

TraceabilityV2 / TraceCodeGenLib / FileWriter

Home

TraceCodeGenerator Lib

#FileWriter This class is used to write code generated from generators implementing IClassGenerator. The writer may safely be reused to write multiple class files.

The built in pathing mechanism assumes that a console application is running the file generation process. It also assumes that the folder containing the console project is in the root folder. The namespace from the IClassGenerator will be parsed as though each field is a folder. Thus a namespace of "BaseProject.SubProject.Group" means that the file will be written to "SolutionRoot/BaseProject/SubProject/Group/".

If it is necessary to write a new pathing mechanism, see FileSupport for the necessary interface and default PathGenerator

##Constructors

###FileWriter(IPathGenerator pathGenerator = null) Constructs a FileWriter.

####pathGenerator Optional override provided in theevent someone wishes to use different pathing during file writing. On success, it returns the full filepath where the new file was written. If there is an error, it will return the error message.

##Methods

###public string CreateFile(IClassGenerator classGen, string filename = null, string directory = null) Writes a file to disk based on the parameters given.

####classGen An IClassGenerator that will produce the code to be written to disk.

####filename Optional override. This file name will be used instead of the one created by the IClassGenerator.

####directory Optional override to change the directory where the the file will be written.

###public IFileWriter DiagnosticOnly(bool activate) Turns diagnostic mode on. When on, the file will not be written, but the path will still be output.

####activate Passing in true will activate diagnostic mode, passing in false will turn it off. By default it is off.

Updated