External Folder

<< >>

Navigation:  CodeStencil > Code Tree > Nodes > Node Types >

External Folder

This node type enables CodeStencil to copy file(s) from a folder to the folder the node is created in.

 

 

CS_clip0202

 

From the screen shot:

 

(1) This is an "External Folder" node and it has been created under the Model folder.

(2) In the node details you can see the source folder the files are going to be copied from - c:\codestencil\generated\ef-scaffold-folder.

(3) This shows the target path of the copied files

(4) In the comments section of the node form, we can see some descriptive text:

 

(a) The [ExcludeLinesContaining] string lets the code generation engine know that there is some post-processing required for the copied file(s). In this case some lines have to be removed.

 

(b) The [%DB_CONTEXT%] indicates the files that needs post-processing. So, during code generation this string is expanded ( or transformed) to get the actual name of the physical file. To reference more that one file, all you have to do is to list the files separated by commas.

 

(c) These lines of text are the lines we want to remove from the derived file in (b)

#warning To protect potentially sensitive information

optionsBuilder.UseSqlServer

 

 

Scenario

A typical scenario that describes the feature mentioned above can be seen when Entity Framework is used to scaffold entity type classes.

The dbcontext file is always generated with the connection string in the OnConfiguring method. Of course, you can manually remove this after code generation, but one of the strengths of CodeStencil is the ability to manipulate how your code is generated.

 

CS_clip0204

 

After that node has been processed, this is what your code will look like:

 

CS_clip0205