Yesterday I read trough the LLBLGen SDK/Template studio documentation.
At the end of the day I come up with my first customized template
After learning some of the inside workings of LLBLGen code generation, and the built-in customization capabilities, I can only think things like:
*) WOW
*) ...this is COOL!
*) Ehi! It's extremely flexible!
*)...
Now let's back to the business
My first template simply create a GeneralEntityFalidatorFactory.
So I have a shared method that create an entity validator from the EntityType.
I use this method in the commonBaseClass (from the 3rd party CommonBaseClass template).
The purpose is to have a flexible way of instantiate the right Validator for each entity.
This is flexible because if I need to create specialized version of a particular EntityValidator, I can easily extend the generated GeneralEntityValidatorFactory to return the extender validator.
And using the extended GeneralEntityValidatorFactory instead of the standard one, will do the job when I will need to develop the personalization we are thinking about
Maybe that a GeneralEntityValidator Template is a useful addition to LLBLGen Pro; if this is the case, here is the code of my template (It’s only VB, I’m unsing it with LLBLGen 2.0/Adapter).
' ///////////////////////////////////////////////////////////////
' // This is generated code.
' //////////////////////////////////////////////////////////////
' // Code is generated using LLBLGen Pro version: <[LLBLGenVersion]>
' // Code is generated on: <[Time]>
' // Code is generated using templates: <[TemplateName]>
' // Templates vendor: ____________
' // Templates version: <[TemplateVersion]>
' //////////////////////////////////////////////////////////////
Imports System
Imports <[RootNamespace]>.EntityClasses
Imports <[RootNamespace]>.HelperClasses
Imports SD.LLBLGen.Pro.ORMSupportClasses
<[ UserCodeRegion "AdditionalNamespaces" ]>
' __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
' __LLBLGENPRO_USER_CODE_REGION_END
<[ EndUserCodeRegion ]>
Namespace <[RootNamespace]>.FactoryClasses
<[If HasEntity]>
<Serializable()> _
Public Class GeneralEntityValidatorFactory
Public Shared Function Create(validatorEntityTypeToCreate As EntityType) As IValidator
Select Case validatorEntityTypeToCreate
<[Foreach Entity CrLf]> Case <[RootNamespace]>.EntityType.<[CurrentEntityName]>Entity
Return New <[RootNamespace]>.ValidatorClasses.<[CurrentEntityName]>Validator()<[NextForeach]>
Case Else
Throw New ArgumentException("Unexpected entity type! validatorEntityTypeToCreate=" & validatorEntityTypeToCreate.ToString,"validatorEntityTypeToCreate")
End Select
End Function
End Class
<[EndIf]>
End Namespace
Bye, Max