ElementTemplate Extension Methods

Discussion created by rdavin Employee on Nov 16, 2011
Latest reply on Nov 17, 2011 by rdavin

This topic touches includes element templates for AFElements, AFEventFrames, and AFNotifications, so I decided it belongs in the general AF forum.  For a couple of years, I happily used code like the AFDatabase.ElementTemplates method.  That was all fine-and-dandy because all I ever dealt with at that time was AFElements.  Recently  I started working with event frames first, followed by notifications.  Apparently all are included as one big happy family in the ElementTemplates call, which wasn’t what my application required.


I noticed that PISystem Explorer is smart enough to compartmentalize or ‘pigeon hole’ them into their respective isolated groups.






I needed to do something similar in my own code and it was easy enough to figure out.  I wrote my own extension methods to achieve the same thing.  It should come in handy for the task at hand.


One thing I noticed was that event frame templates do not have their very own AFIdentity.  I was expecting it to be EventFrameTemplate but that doesn’t exist.  Rather it was simply ElementTemplate.  The question that comes to mind then is whether this an ElementTemplate for an AFElement or an AFEventFrame, as both have the same AFIdentity.  This can be determined by looking at the templates InstanceType property.


Notification element templates do have their own AFIdentify of NotificationTemplate.  I decided I may as well strong type their named collection to be AFNotificationTemplate instead of the generic AFElementTemplate.


Sample code follows in next post.