Extra placeholders to be used in folder names

Posts   
 
    
Jan VBM avatar
Jan VBM
User
Posts: 24
Joined: 03-Apr-2011
# Posted on: 18-Jun-2011 22:25:22   

L.S.,

I'm using LLBLGenPro 3.1 Final February 7th, 2011, the LLBLGenPro Runtime Framework.

I'm working with a mix of TDL and Lpt C# templates to generate parts of a WCF framework (VS2008, C#), I'm looking into the possibilities for controlling my code generation through frameworksettings files, where settingDefinitions can be set at project, entity, and other target elements with help of for example value lists and default values. It is clear how these settings can be accessed (in Lpt:

string dbSpecificFileSuffix = currentProject.GetRealStringSettingValue("AdapterDbSpecificProjectFileSuffix");)

. For folder and foldernames I would like to create extra placeholders on top of the known ones ( [dbgenericSubFolder], [dbspecificSubFolder], [driverShortName], [databaseShortName] )that the ProjectFileCreator recognizes (through HandleDestinationFolder?).

So my Question is: How can I get more/extra placeholders to be used in the folder names to create?

tnx

Jan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jun-2011 20:40:48   

Hi Jan,

So, let me see if I get this straight: you want to create a custom placeholder (say: [wcfSubFolder]) you can use in destinationFolder parameter of the ProjectFileCreator task performer. Right?

Well, the built-in ProjectFileCreator task performer doesn't know how to read your custom settings values, so you will need to follow these steps:

  1. Write your own .frameworksettings file so you can define your new setting "WCFProjectSubFolderName".

  2. You have to create your own version of the ProjectFileCreator task performer and override the HandleDestinationFolder method. Example:

public class MyProjectFileCreator : ProjectFileCreator
{
    protected override string HandleDestinationFolder(string folderFormat)
    {
        string baseDestinationFolder = base.HandleDestinationFolder(folderFormat);
        
        // do a replace finding your [wcfSubFolder] placeholder and replace it with your setting value
        // you need to implement this HandleDestinationFolederWithWcfSubFolder method.
        string newDestinationFolder = HandleDestinationFolederWithWcfSubFolder(baseDestinationFolder);

       return newDestinationFolder ;
    }
}
  1. Compile your new task performer and place it in your custom task performer directory.

  2. At your custom wcf .tasks file, be sure to specify your new task performer assembly

<task name="Tostil.CustomStuff.WCF.ProjectCreator" assemblyFilename="Tostil.CustomStuff.TaskPerformers.dll" 
            taskPerformerClass="Tostil.CustomStuff.TaskPerformers.MyProjectFileCreator" 
            description="Generates my WCF project file" isOptional="false">

That's it. If you want to use your new placeholder in other task performers (CodeEmitter, LptParser) you will need to do the same for those.

If you need further help on this please let us know.

David Elizondo | LLBLGen Support Team
Jan VBM avatar
Jan VBM
User
Posts: 24
Joined: 03-Apr-2011
# Posted on: 23-Sep-2014 19:13:23   

L.S., I'm currently making some changes to the TaskPerformers, in line with the recommendations in thread 19979 for example to be able to work with custom placeholders, i.e. through adding my own version of the ProjectFileCreator / CodeEmitter task and override the HandleDestinationFolder method.

I'm working in the September 2014 sources of the Task Performers, and using (copy-pasting) the [documented] changes that I did some time ago in LLBLGenPro 3.1 Final February 7th, 2011 sources (which worked fine).

When I start adding an override for HandleDestinationFolder in exactly the same manner as it worked with version 3.1 sources and try to compile/rebuild, Visual Studio complains about:

'COWI.TaskPerformers.CodeEmitter.HandleDestinationFolder(string)': cannot override inherited member 'SD.LLBLGen.Pro.GeneratorCore.TaskPerformerBase.HandleDestinationFolder(string)' because it is not marked virtual, abstract, or override

Below the code of the override in my custom version of the taskperformer, any ideas on what I need to do ?


        protected override string HandleDestinationFolder(string folderFormat)
        {
            string baseDestinationFolder = base.HandleDestinationFolder(folderFormat);
            string newDestinationFolder = baseDestinationFolder;

            Helper helper = new Helper();
            newDestinationFolder = helper.HandleDestinationFolder(this.ExecutingGenerator, newDestinationFolder);

            return newDestinationFolder;
        }

tnx

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 23-Sep-2014 22:00:54   

The method is not overridable indeed. As a workaround, you can create your own method in your task performer, and use it instead of using the HandleDestinationFolder method.

Jan VBM avatar
Jan VBM
User
Posts: 24
Joined: 03-Apr-2011
# Posted on: 24-Sep-2014 18:21:08   

That works indeed, thanks. Note that the original instruction in this thread on

creating your own version of the ProjectFileCreator task performer and override the HandleDestinationFolder method

based on version 3.1 source code does not work in v4.1 sources.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 24-Sep-2014 18:29:30   

We'll look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 25-Sep-2014 15:55:30   

The method has a different signature in v4.x:

protected virtual string HandleDestinationFolder(string folderFormat, string groupName, string elementName)
{
    Project currentProject = this.ExecutingGenerator.ProjectDefinition;
    string dbSpecificSubFolder = currentProject.GetRealStringSettingValue("AdapterDbSpecificSubFolderName");
    string dbGenericSubFolder = currentProject.GetRealStringSettingValue("AdapterDbGenericSubFolderName");
    string toReturn = ReplaceDatabaseDriverShortNames(folderFormat.Replace("[dbspecificSubFolder]", dbSpecificSubFolder)
                                                                    .Replace("[dbgenericSubFolder]", dbGenericSubFolder)
                                                                    .Replace("[elementName]", elementName ?? string.Empty)
                                                                    .Replace("[groupName]", groupName ?? string.Empty));
    return toReturn.StartsWith(@"\") ? toReturn.Substring(1) : toReturn;
}

HandleDestinationFolder(folderFormat), simply does: return HandleDestinationFolder(folderFormat, string.Empty, string.Empty);

Hope this helps simple_smile

Ps, please check the designer reference manual available on the website, this allows you to check the available methods in the various classes, including TaskPerformerBase.

Frans Bouma | Lead developer LLBLGen Pro