Hi,
I would like to change splitRegex in this action to split passed string into 3 groups (filename and content, and a folder name to which class will be added), instead of current two (filename and content). Currently all templates generates one string for all business entities and we have string like:
//begin "Client.cs"
here is the content
//end "Client.cs"
To do that I have modified all templates to add folder name and I have added something like this:
// begin "Client.cs"
// folderName "Client"
here is the content
//end "Client.cs"
So in this case I have to change splitRegex to get value which is after this text '// folderName ' and in within "" to be my folder name.
Code Snippet
// begin "filename"
here is the content
// end "filename"
For more information here is the regex I would like to change:
Code Snippet
static readonly Regex splitRegex = new Regex(@"^// name ""(?<name>[^""]+)""\n^// begin ""(?<filename>[^""]+)"".?$\n(?<content>.*)^// end ""\k<filename>"".?$", RegexOptions.Multiline | RegexOptions.Singleline);
and here is code of a "Execute" method which splits generated string into separate files and where I would like to get folder name:
Code Snippet
const string FilenameGroups = "filename";
const string ContentGroups = "content";
const string FolderNameGroups = "folderName";
public override void Execute()
{
DTE vs = GetService<DTE>(true);
projectItems = new List<EnvDTE.ProjectItem>();
for(Match match = splitRegex.Match(content); match.Success; match = match.NextMatch())
{
string relativeFileName = match.Groups[FilenameGroups].Value;
string fileName = Path.GetFileName(relativeFileName);
string relativeTargetPath = Path.GetDirectoryName(relativeFileName);
... here I would like to get folder name like:
string relativeFileName = match.Groups[FolderNameGroups ].Value }
}
TIA,
Kind Regards,
Lukasz