Working on a plugin

Posts   
 
    
ssifrank
User
Posts: 3
Joined: 25-Apr-2012
# Posted on: 25-Apr-2012 00:29:16   

I have written a plugin to tweak names and it's working for Tables and Fields but I also want to run against Relationships and Navigators but can't see how.

    public override void Execute()
    {
        foreach (var item in this.Entities)
        {
            base.ProgressSubtaskStart("Processing: " + item.Name);
            item.Name = this.FixName(item.Name);
            base.LogLineToApplicationOutput(string.Format("New Name - {0}", item.Name), "Fix naming conventions", true, true);
            foreach (var field in item.Fields)
            {
                field.Name = this.FixName(field.Name);
                base.LogLineToApplicationOutput(string.Format("New Name - {0}.{1}", item.Name, field.Name), "Fix naming conventions", true, true);
            }
            base.ProgressSubtaskComplete();
        }
    }

    private string FixName(string name)
    {
        string newName = "";

        bool capitalize = true;

        foreach (char item in name)
            if (item == '_')
                capitalize = true;
            else
            {
                newName += capitalize ? item.ToString().ToUpper() : item.ToString();
                capitalize = false;
            }

        return newName;
    }

Any ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Apr-2012 05:23:40   

What LLBLGen version are you using? Also, the ApplicationCore_ReferenceManual is a good place to get used to the class structure. You can download it from the Customer Area.

David Elizondo | LLBLGen Support Team
ssifrank
User
Posts: 3
Joined: 25-Apr-2012
# Posted on: 26-Apr-2012 15:31:04   

Thanks for the reply. I'm using v3 and like I said I am able to make all the entity and field name changes I want but cannot find a way to access and change navigator names with a plugin when reverse engineering. I have been thru the SDK code for plural and singular and can change it and use visual studio to debug I'm either attaching to the wrong event or something else. My main plugin is attached to EntitiesAfterAdd to loop thru Entities and the Fields for each entity.

Also is this the manual you mentioned? LLBLGenPro.RTL.ReferenceManual.chm

Frank

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Apr-2012 07:28:27   

ssifrank wrote:

Thanks for the reply. I'm using v3 and like I said I am able to make all the entity and field name changes I want but cannot find a way to access and change navigator names with a plugin when reverse engineering. I have been thru the SDK code for plural and singular and can change it and use visual studio to debug I'm either attaching to the wrong event or something else. My main plugin is attached to EntitiesAfterAdd to loop thru Entities and the Fields for each entity.

Given an entityDefinition, you can access its navigators and change their names with some code like this:

// here 'p' is the current Project object
var relationships = p.GetAllRelationshipsForEntity(entity, true);

foreach (RelationshipEdge rel in relationships)
{
    rel.StartEntityNavigator = rel.StartEntityNavigator + "X";
    rel.EndEntityNavigator = rel.EndEntityNavigator + "X";
}

ssifrank wrote:

Also is this the manual you mentioned? LLBLGenPro.RTL.ReferenceManual.chm

That is for the runtime library (the classes you use in your generated code). The one I'm talking about is titled "LLBLGen Pro v3.0 designer assemblies reference manual" at the **Customer Area->v3.0 downloads->Documentation. **. The actual file is "LLBLGenPro.CoreAssemblies.ReferenceManual.chm" but you have to grab it from the download section.

David Elizondo | LLBLGen Support Team
ssifrank
User
Posts: 3
Joined: 25-Apr-2012
# Posted on: 27-Apr-2012 16:31:35   

Thanks for the reply!

Exactly what I needed. Great product.

Frank