This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,Any planned support for value convertors, especially for byte arrays.
Something along the lines of an attribute taking a class type that implements a conversion interface. In my current domain objects I implement conversion once and cache the converted value, however, I must override OnSaving to serialize any possible changes in the converted type back to the byte array. It certainly would reduce the chance for errors and not to mention pretty-up the code. Thanks, Kavan |
|
|
Hi Kavan, Why couldn't you simply add the conversion logic to the property? For example (pseudo code): public BitmapImage Image As LightSpeed only maps to the fields you can add any additional logic to the properties that you desire. I can't see how this would have any more errors than using an attribute based approach given in both cases you would only run into errors if you forgot to apply the conversion to your code. You mention caching the value, can I assume that your conversion process is intensive and perhaps may not suit being apply on every property access? I'm interested in finding out more about your use case to try and understand if this would be an important addition to LightSpeed in the near future. We actively try and keep the number of attributes low however we do appreciate feature requests as they do help shape the future of LightSpeed. Hope that helps, John-Daniel |
|
|
Hi John-Daniel, In WinForms databinding a property's get accessor will be hit many times. So caching a property conversion only makes sense. However, sometimes caching is mandatory for data integerty irregardless how intensive the conversion process is. Please allow me to explain below. In my specific situation I am keeping UI preferences and the such in a class that would be pulled when the object is loaded and not sent back to the property setter till saved. Now the problem becomes if I write code like this:
On the second line my PrefObject is being "reconverted" from the field on the property get and the previous change is lost. So you see I am actually caching the first conversion so that I am returning the same converted object back on subsequent gets. And that leads to another point, a byte[] is like a value object, but a class object is a reference to its data and will also change in response to many stimuli. So what I would really like to be able to have in LightSpeed is a BO like this.
The above declaration would not only solve the first problem above, but since MyPrefObject is stored in the field (which LightSpeed serializes) any changes to MyPrefObject will be recaptured automatically when the entity is saved. And since the convertor mechanism is in LightSpeed it can translate the PrefObject back to the byte[] I hope this may shed some light on my particular situation. I am currently in the process of converting a project with over a 100 BOs to LightSpeed, however the model makes heavy use of objects like the PrefObject. Thanks for all the great work, Kavan |
|