mvvm-light: Should we merge Cleanup methods in locator?
when creating a new ViewModel within the locator class using the snippet it creates a Cleanup Method but there is already one available from the Main so hence an error....
Should we merge them all??
Or should we be renaming the method to Cleanup[Name of viewmodel] for example.
I am a little confused here
Another question i would like to ask is regards to the naming conventions.
I tried to follow the naming convention used with "MAIN"...
hence i have CreateLogin, ClearLogin, Login (non static property for binding) etc etc..
Would it not be better to use CreateLoginViewModel, ClearLoginViewModel etc??
Just curious开发者_如何学Python
Thanks
This snippet (and the ViewModelLocator in general) need work, and it is going to be a major change in V4.
Yes, the intent was to merge the Cleanup method generated by the snippet with the one already available. The idea is that you can just call ViewModelLocator.Cleanup() and have all the VMs clean themselves up (for example persisting their state to local storage, closing streams, etc...). Since a snippet cannot modify an existing method, I decided to just duplicate the Cleanup method. It won't compile, so the developer should know to merge them.
That said, it is not satisfactory to have a CreateMain, ClearMain etc for each VM type. I think we all agree that this is a weak implementation, and I want to improve it by providing a generic ViewModelLocator in the future (V4).
Regarding naming conventions, they are just conventions. I was tired to type "ViewModel", but feel free to use your own convention. As I said, the snippet will probably not be needed in V4 anymore. Apologies in the meantime for the inconvenience ;) (note that you can easily modify the snippet if you want to)
Cheers, Laurent
精彩评论