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 - i'm trying to find out whether i can enforce a factory for a particular entity. i suspect there is some way out there but can't quickly find it from the API docs or forum search... this post seems relevant: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=1116 I know LS needs to be able to new up an entity with a default constructor for various reasons but what i'd like is to say is for this particular entity, anyone creating one must pass in some initialisation values. normally i'd do this through a factory creation method or enforcing parameters on the constructor. what is the best approach to take here? does LS allow me to say there is no public default constructor? cheers justin |
|
|
No. LightSpeed requires a public default constructor. I don't believe it will be feasible for us to support types with only parameterised constructors or parameterised factory methods, because then we'd somehow need to know what parameters to call them with. Probably the best we could do is to support non-public default constructors. (I'm a bit reluctant to do factory methods because they don't guarantee to return new objects, which could result in strange interactions.) This would however have a performance impact (as we would need to use reflection to call the constructors) and would work only if the LightSpeed code had full trust (e.g. might cause problems if the application was running from a network drive). |
|