C2021-056 Added FirstWord flag to ReplaceWords
C2021-056 Added logic to support the FirstWord flag in ReplaceWords. When set, the word will be replaced only if it the first word in the text.
This commit is contained in:
@@ -2077,10 +2077,11 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
bool dopartial = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.Partials) == E_ReplaceFlags.Partials;
|
||||
bool onlyDoList = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.BeforeList) == E_ReplaceFlags.BeforeList; // C2021-045
|
||||
bool onlyIfFirstWord = (E_ReplaceFlags)(rs.Flag & FormatConfig.E_ReplaceFlagsUCF.FirstWord) == E_ReplaceFlags.FirstWord; // C2021-056
|
||||
|
||||
// note that the order of this check is important. Check in this order...
|
||||
// background here
|
||||
if (!shouldReplace.ContainsKey((E_ReplaceFlags)rs.Flag))
|
||||
if (!shouldReplace.ContainsKey((E_ReplaceFlags)rs.Flag))
|
||||
{
|
||||
//int profileDepth2 = ProfileTimer.Push(">>>> Before ShouldReplaceIt");
|
||||
shouldReplace.Add((E_ReplaceFlags)rs.Flag, ShouldReplaceIt((E_ReplaceFlags)rs.Flag));
|
||||
@@ -2088,9 +2089,15 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
bool replaceit = shouldReplace[(E_ReplaceFlags)rs.Flag];
|
||||
|
||||
// C2021-045 if the BeforeList ReplaceWords flag is set, only do the replace word if the text ends with a colon
|
||||
if (replaceit && onlyDoList && !Text.EndsWith(":"))
|
||||
replaceit = false; // text does not end with a colon so don't replace this word
|
||||
if (replaceit)
|
||||
{
|
||||
// C2021-045 if the BeforeList ReplaceWords flag is set, only do the replace word if the text ends with a colon
|
||||
if (onlyDoList && !Text.EndsWith(":"))
|
||||
replaceit = false; // text does not end with a colon so don't replace this word
|
||||
// C2021-056 if FirstWord ReplaceWords flag is set, only do if the replace word is the first word in the text
|
||||
if (onlyIfFirstWord && !Text.StartsWith(rs.ReplaceWord))
|
||||
replaceit = false;
|
||||
}
|
||||
if (!replaceit && _DoReplWordInPageList) replaceit = true; // F2021-053: Do replace words in page list
|
||||
if (replaceit)
|
||||
{
|
||||
|
Reference in New Issue
Block a user