I have a multi-language system, and all over the place I have what I would call "wrapper properties" in every class, such as:
Public Property Name(Optional ByVal ForceLanguageCode As String = Nothing) As String
Get
Return Translations.GetByCode(Me.EntityID, "name", ForceLanguageCode)
End Get
Set(ByVal value As String)
Translations.SetByCode(Me.EntityID, "name", value, ForceLanguageCode)
End Set
End Property
I would then copy and paste that code for every translatable field.
I am hoping to be able to replace that with one line of code somehow, with a class. The only thing that changes each time is the name of the field, such as "name", "title", or "subject", etc. This seems a bit of a waste and I want my system to be as easy to use as possible for developers.
I did some research into attributes but I don't think that is my answer as:
1) I don't know how to automatically instantiate the objects, especially as this is extending a LINQ entity where the New() signature is already generated by the DBML. My current technique uses static functions.
2) The "EntityID" is realtime information, not compile-time.
Could anybody suggest how I could clean up this mess?