OpenPetra
Free Administration Software for Non-Profits
Ict.Common.IO.ProcessTemplate Class Reference

this class helps with template scripts and other text files More...

Public Member Functions

 ProcessTemplate (string AFullPath=null)
 constructor, open template from file More...
 
void AddSnippetsFromOtherFile (string AFilePath)
 add snippets from another template file (eg. for writing datasets, we want to reuse the table template for custom tables) More...
 
ProcessTemplate GetSnippet (string ASnippetName)
 get the specified snippet, in a new Template More...
 
void InsertSnippet (string ACodeletName, ProcessTemplate ASnippet)
 insert the snippet into the current template, into the given codelet More...
 
void InsertSnippet (string ACodeletName, ProcessTemplate ASnippet, string ASeparator)
 insert the snippet into the current template, into the given codelet. use separator to separate from previous items inserted into that codelet More...
 
void InsertSnippetPrepend (string ACodeletName, ProcessTemplate ASnippet)
 insert the snippet into the current template, into the given codelet. add new text in front of the text that has already been added to the codelet More...
 
Boolean CheckTemplateCompletion (StringBuilder s)
 check if all placeholders have been replaced in the template; ignore IFDEF More...
 
void ProcessIFDEFs (ref StringBuilder sb)
 remove all ifdefs that are not defined, or activate them More...
 
void SetCodeLetPostfix (string APostfix)
 set the postfix for codelets. this helps to distinguish codelets when nesting codelets More...
 
void AddToCodelet (string APlaceholder, string ACodelet)
 add code to existing code that will be replaced later More...
 
string AddSeparatorToCodelet (string APlaceholder, string ASeparator)
 add separator to codelet at the end of the previous row More...
 
void AddToCodeletPrepend (string APlaceholder, string ACodelet)
 
void AddToCodeletPrepend (string APlaceholder, string ACodelet, bool AAllowDuplicates)
 
void AddToCodelet (string APlaceholder, string ACodelet, bool AAddDuplicates)
 add code to existing code that will be replaced later More...
 
void SetCodelet (string APlaceholder, string ACodelet)
 create a new codelet, overwrites existing one More...
 
void SetCodeletComment (string APlaceholder, string AMultiLineComment)
 special way of splitting a multiline comment into several lines with comment slashes More...
 
void ReplacePlaceHolder (string APlaceholder, string AValue, string ADefault)
 add replacement to the list of codelets More...
 
void ReplacePlaceHolder (string APlaceholder, string AValue)
 replace a placeholder with an actual value. overload with empty default. More...
 
Boolean ReplaceRegion (string regionName, string content)
 replace a region with new content More...
 
Boolean processTemplateParameters (XmlNode curNode)
 insert parameters into placeholders More...
 
void BeautifyCode (ref StringBuilder s)
 clean up the code, remove spaces, too many empty lines More...
 
Boolean FinishWriting (string AXAMLFilename, string ADestFileExtension, Boolean ACheckTemplateCompletion)
 write the content to a file. deal with conditional defines etc. More...
 
string FinishWriting (Boolean ACheckTemplateCompletion)
 return the snippet as a string, instead of writing to file More...
 

Static Public Member Functions

static string LoadEmptyFileComment (string ATemplatePath)
 load the license and copyright text for the file header More...
 

Public Attributes

StringBuilder FTemplateCode = new StringBuilder()
 the template More...
 
String FDestinationFile = ""
 the name of the file to write to More...
 
SortedList< string, StringBuilder > FCodelets = new SortedList <string, StringBuilder>()
 temporary strings to store code into that will later each be inserted into a placeholder More...
 
SortedList< string, string > FSnippets = new SortedList <string, string>()
 snippets are smaller pieces of template code More...
 
String FCodeletPostfix = ""
 this helps to distinguish codelets when nesting codelets More...
 

Protected Member Functions

void ReplaceCodelets ()
 insert the codelets into the template that have been collected until now More...
 

Detailed Description

this class helps with template scripts and other text files

Constructor & Destructor Documentation

◆ ProcessTemplate()

Ict.Common.IO.ProcessTemplate.ProcessTemplate ( string  AFullPath = null)
inline

constructor, open template from file

Parameters
AFullPath

Member Function Documentation

◆ AddSeparatorToCodelet()

string Ict.Common.IO.ProcessTemplate.AddSeparatorToCodelet ( string  APlaceholder,
string  ASeparator 
)
inline

add separator to codelet at the end of the previous row

◆ AddSnippetsFromOtherFile()

void Ict.Common.IO.ProcessTemplate.AddSnippetsFromOtherFile ( string  AFilePath)
inline

add snippets from another template file (eg. for writing datasets, we want to reuse the table template for custom tables)

Parameters
AFilePath

◆ AddToCodelet() [1/2]

void Ict.Common.IO.ProcessTemplate.AddToCodelet ( string  APlaceholder,
string  ACodelet 
)
inline

add code to existing code that will be replaced later

◆ AddToCodelet() [2/2]

void Ict.Common.IO.ProcessTemplate.AddToCodelet ( string  APlaceholder,
string  ACodelet,
bool  AAddDuplicates 
)
inline

add code to existing code that will be replaced later

Parameters
APlaceholder
ACodelet
AAddDuplicates
Returns

◆ AddToCodeletPrepend() [1/2]

void Ict.Common.IO.ProcessTemplate.AddToCodeletPrepend ( string  APlaceholder,
string  ACodelet 
)
inline

add code to existing code that will be replaced later. the new code is added before the existing code. this overload allows duplicates to be added

◆ AddToCodeletPrepend() [2/2]

void Ict.Common.IO.ProcessTemplate.AddToCodeletPrepend ( string  APlaceholder,
string  ACodelet,
bool  AAllowDuplicates 
)
inline

add code to existing code that will be replaced later. the new code is added before the existing code

◆ BeautifyCode()

void Ict.Common.IO.ProcessTemplate.BeautifyCode ( ref StringBuilder  s)
inline

clean up the code, remove spaces, too many empty lines

Parameters
s
Returns

◆ CheckTemplateCompletion()

Boolean Ict.Common.IO.ProcessTemplate.CheckTemplateCompletion ( StringBuilder  s)
inline

check if all placeholders have been replaced in the template; ignore IFDEF

◆ FinishWriting() [1/2]

string Ict.Common.IO.ProcessTemplate.FinishWriting ( Boolean  ACheckTemplateCompletion)
inline

return the snippet as a string, instead of writing to file

◆ FinishWriting() [2/2]

Boolean Ict.Common.IO.ProcessTemplate.FinishWriting ( string  AXAMLFilename,
string  ADestFileExtension,
Boolean  ACheckTemplateCompletion 
)
inline

write the content to a file. deal with conditional defines etc.

Parameters
AXAMLFilename
ADestFileExtension
ACheckTemplateCompletion
Returns

◆ GetSnippet()

ProcessTemplate Ict.Common.IO.ProcessTemplate.GetSnippet ( string  ASnippetName)
inline

get the specified snippet, in a new Template

Parameters
ASnippetName
Returns

◆ InsertSnippet() [1/2]

void Ict.Common.IO.ProcessTemplate.InsertSnippet ( string  ACodeletName,
ProcessTemplate  ASnippet 
)
inline

insert the snippet into the current template, into the given codelet

Parameters
ACodeletName
ASnippet

◆ InsertSnippet() [2/2]

void Ict.Common.IO.ProcessTemplate.InsertSnippet ( string  ACodeletName,
ProcessTemplate  ASnippet,
string  ASeparator 
)
inline

insert the snippet into the current template, into the given codelet. use separator to separate from previous items inserted into that codelet

Parameters
ACodeletName
ASnippet
ASeparator

◆ InsertSnippetPrepend()

void Ict.Common.IO.ProcessTemplate.InsertSnippetPrepend ( string  ACodeletName,
ProcessTemplate  ASnippet 
)
inline

insert the snippet into the current template, into the given codelet. add new text in front of the text that has already been added to the codelet

Parameters
ACodeletName
ASnippet

◆ LoadEmptyFileComment()

static string Ict.Common.IO.ProcessTemplate.LoadEmptyFileComment ( string  ATemplatePath)
inlinestatic

load the license and copyright text for the file header

Parameters
ATemplatePath
Returns

◆ ProcessIFDEFs()

void Ict.Common.IO.ProcessTemplate.ProcessIFDEFs ( ref StringBuilder  sb)
inline

remove all ifdefs that are not defined, or activate them

◆ processTemplateParameters()

Boolean Ict.Common.IO.ProcessTemplate.processTemplateParameters ( XmlNode  curNode)
inline

insert parameters into placeholders

Parameters
curNode
Returns

◆ ReplaceCodelets()

void Ict.Common.IO.ProcessTemplate.ReplaceCodelets ( )
inlineprotected

insert the codelets into the template that have been collected until now

◆ ReplacePlaceHolder() [1/2]

void Ict.Common.IO.ProcessTemplate.ReplacePlaceHolder ( string  APlaceholder,
string  AValue 
)
inline

replace a placeholder with an actual value. overload with empty default.

Parameters
APlaceholder
AValue

◆ ReplacePlaceHolder() [2/2]

void Ict.Common.IO.ProcessTemplate.ReplacePlaceHolder ( string  APlaceholder,
string  AValue,
string  ADefault 
)
inline

add replacement to the list of codelets

Parameters
APlaceholder
AValue
ADefault
Returns

◆ ReplaceRegion()

Boolean Ict.Common.IO.ProcessTemplate.ReplaceRegion ( string  regionName,
string  content 
)
inline

replace a region with new content

Parameters
regionName
content
Returns

◆ SetCodelet()

void Ict.Common.IO.ProcessTemplate.SetCodelet ( string  APlaceholder,
string  ACodelet 
)
inline

create a new codelet, overwrites existing one

◆ SetCodeletComment()

void Ict.Common.IO.ProcessTemplate.SetCodeletComment ( string  APlaceholder,
string  AMultiLineComment 
)
inline

special way of splitting a multiline comment into several lines with comment slashes

◆ SetCodeLetPostfix()

void Ict.Common.IO.ProcessTemplate.SetCodeLetPostfix ( string  APostfix)
inline

set the postfix for codelets. this helps to distinguish codelets when nesting codelets

Parameters
APostfix

Member Data Documentation

◆ FCodeletPostfix

String Ict.Common.IO.ProcessTemplate.FCodeletPostfix = ""

this helps to distinguish codelets when nesting codelets

◆ FCodelets

SortedList<string, StringBuilder> Ict.Common.IO.ProcessTemplate.FCodelets = new SortedList <string, StringBuilder>()

temporary strings to store code into that will later each be inserted into a placeholder

◆ FDestinationFile

String Ict.Common.IO.ProcessTemplate.FDestinationFile = ""

the name of the file to write to

◆ FSnippets

SortedList<string, string> Ict.Common.IO.ProcessTemplate.FSnippets = new SortedList <string, string>()

snippets are smaller pieces of template code

◆ FTemplateCode

StringBuilder Ict.Common.IO.ProcessTemplate.FTemplateCode = new StringBuilder()

the template


The documentation for this class was generated from the following file: