Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Custom Templates> If StringValueEquals ... ...
 

Pages: 1
Custom Templates
If StringValueEquals ... ...
Page:1/1 

  Print all messages in this thread  
Poster Message
ChBaeumer
User



Location:
Berlin, Germany
Joined on:
23-Oct-2003 14:44:03
Posted:
175 posts
# Posted on: 30-Mar-2005 18:00:52.  
Hi,

I'm currently writing my own templates.

I want to do following:

Some entities have to implement a specific interface. Since the implementation of this interface is common to this entities I thought I could write a template which injects this code to these entities. Other entities of the project (more or less the (m,n) tables) do not need this interfaces.

Ok, I defined custom properties like (Name, Value): (Interface, <Name of interface>)

In the template I iterate over the properties. That's ok so far.
But if I do following the output looks not OK:

Code:

<[Foreach CustomProperty Entity]><[If StringValueEquals CustomPropertyName "Interface"]>, <[CustomPropertyValue]><[EndIf]><[NextFor]>


Produces following garbage:
Code:

EntityStringValueEqualsCustomPropertyName "Interface"]>, IAssociation


I guess the CustomPropertyName is not allowed in the grammar at this place, but if would be nice to have. Then it would be possible to tag the entities with properties and write templates which act on these properties.

Christoph
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38084 posts
# Posted on: 30-Mar-2005 18:17:44.  
You can't use 'CustomPropertyName' in that if statement so it throws an error.

Do you have more things you'd like to add to that if statement, so I can add them all at once? Regular Smiley


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
ChBaeumer
User



Location:
Berlin, Germany
Joined on:
23-Oct-2003 14:44:03
Posted:
175 posts
# Posted on: 30-Mar-2005 18:54:44.  
Nothing I need right now since I just started to explore the possibilities of the template generator Wink

Things popping in my mind:

- case switch
- else switch

and a kind of grammar (ebnf) would be usefull (at least for me) to see what is possible.

Laugh
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38084 posts
# Posted on: 31-Mar-2005 12:07:47.  
ChBaeumer wrote:
Nothing I need right now since I just started to explore the possibilities of the template generator Wink

Things popping in my mind:

- case switch
- else switch

I think you'd better look at .lpt templates then, TDL is a bit limited to produce custom code, as the object model in the project isn't exposed through statements. .lpt templates can be written in C# or VB.NET, and you can access the complete object model in a project.

Quote:

and a kind of grammar (ebnf) would be usefull (at least for me) to see what is possible.
Laugh

I didn't write an ebnf grammar for TDL because it's a set of statements and don't expose rules like this statement has a special expression block and can't be used inside another statement. The parser is also not LR(n) but LL(1). This is done to easily adjust the language when required without having to worry about shift/reduce conflicts in the LR parser. The parser used for this forum (my LR(n) parser generator combi Wink) for example is very inflexible because changes to the language require severe maintenance and often cause shift/reduce conflicts somewhere... which aren't necessary as TDL is a low level language to write code generation statements with the least amount of statements. The one requirement TDL had to meet was that it was absolutely fail proof and no debugging was required to fix template statements.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Mountain
User



Location:
Florida
Joined on:
01-Apr-2005 05:05:51
Posted:
21 posts
# Posted on: 05-Apr-2005 15:37:10.  
ChBaeumer wrote:

I want to do following:
Some entities have to implement a specific interface. Since the implementation of this interface is common to this entities I thought I could write a template which injects this code to these entities. Other entities of the project (more or less the (m,n) tables) do not need this interfaces.


I have a similar need. I want certain entities to implement certain interfaces.
  • If the database table has a column called "Name", I want the entity to implement the interface called "INamedEntity".
  • If the table has a column called "SequenceID", I want the entity to implement "ISequencedEntity".
  • If the table has a column called "ID", I want the entity to implement "IUniqueEntity".
Those are the only 3 situations I need to handle.

I have not yet edited any template or even opened template studio. What is the quickest way to accomplish what I need?

Would it be possible for you to post the changes I need to make to the C# entityAdapter.template file? I would love to be able to just copy a new version of entityAdapter.template into a folder and get back to work. I hope to be able to learn all about template editing at a later time. Thanks!
  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
38084 posts
# Posted on: 06-Apr-2005 11:16:47.  
That's not possible with TDL as in: TDL doesn't have these check commands.

Well, it is possible, but it's not that fast:

You could loop over the entityfields and check the SourceColumnName in an enclosed If statement. The header of the entity class in the 1.0.2004.1 version of the entityAdapter.template will then become:

Code:

public class <[CurrentEntityName]>Entity : EntityBase2, ISerializable<[Foreach EntityField]><[If StringValueEquals SourceColumnName "Name"]>, INamedEntity<[EndIf]><[If StringValueEquals SourceColumnName "SequenceID"]>, ISequencedEntity<[EndIf]><[If StringValueEquals SourceColumnName "ID"]>, IUniqueEntity<[EndIf]><[NextForeach]>


For 1.0.2004.2, you've to alter the new template also of course. If you want to test on Entity Field names instead of table field names, use EntityFieldName instead of SourceColumnName Regular Smiley



Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.