EntityField2 get to parent Entity?

Posts   
 
    
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 14-May-2010 15:39:49   

I have a need for lots of custom properties at both the entity and entityfield level. I don't want developers to have to go at them via hashtables and string identifiers. So I've customized some templates and I'm trying to generate these custom fields as properties on the EntityFields helper classes.

For example, one set of custom field properties are DisplayName, DisplayFormat and FieldGUID (for localization). I've created an EntityField3 class in an extensions dll and modified all the required templates so that I can get at that and now the factory is newing my EntityField3 with all my new custom properties as direct access properties.

However, my custom field properties are attached to a static hashtable on the entity itself and I don't see a way to get to this (without getting into reflection) from the EntityField.

Is there any way to do this?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-May-2010 05:16:47   

I see. Could you please show us (attach) the modified template you have?

David Elizondo | LLBLGen Support Team
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 19-May-2010 05:01:16   

I've attached the templates. The EntityField3 class is in my LLBLExtensions project.


 public class EntityField3 : EntityField2, IEntityField3
    {

        public string DisplayName
        {
            get
            {
                return ""; // how do I get to the custom field properties from here without using reflection?
            }
        }


        /// <summary>
        /// CTor
        /// </summary>
        /// <param name="fieldInfo">The field info.</param>
        public EntityField3( IFieldInfo fieldInfo) : base(fieldInfo)
        {
        }


  .... lots of constructors


Attachments
Filename File size Added on Approval
entityFieldFactoryAdapter.template 2,890 19-May-2010 05:01.41 Approved
fieldCreationClassesAdapter.template 2,165 19-May-2010 05:01.50 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-May-2010 07:04:28   

At template level you can access such custom properties to emit code. Please take a look at DBEditor Asp.Net templates (LLBLGen Site Customer's area-> v2.6 Downloads -> Templates) to see how custom properties are accessed from templates.

David Elizondo | LLBLGen Support Team
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 19-May-2010 16:35:33   

I'm confused. Those scripts use <% %> which doesn't get processed for me when I run the llbl generator.

Also, in the templates that I've built on, all that is passed through in the generated code is a fieldindex. There's no currentfield entity or anything in the template or generated code.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-May-2010 04:15:00   

Ok, the difference is that ASP.Net GUI templates use Lpt templates engine (.lpt temlates), and you used Template Definition Language (TDL). The former gives you more power and flexibility on what you need to generate. The later is for straight forward code generation that doesn't need complex generation logic.

LPT is preferred when you need access and manipulate objects to get the final generation code. Please read the SDK manual for more details. You can use the ASP.Net GUI templates to get an idea of how access custom properties to generate custom code.

David Elizondo | LLBLGen Support Team