c# - MVVM and DI - How to handle Model objects? -
I am using Caliburn and C # but I think this is a normal MVVM / DI question.
Here are some code:
class NoteViewModel: PropertyChangedBase {Private note-only note _ note; Public note-visual model (note note) {_note = note; } Public string title {get {return_note.Title; } Set {_note.Title = value; NotifyOfPropertyChange ((=) => header);
Now this object is created by passing new () and a model object.
Well, it works fine, but now I have to add a method that requires an imported class from my DI container.
Do I call the service agent only. Currently to get it? Or should I design this visual model to prepare it through a de detector and in some way should a way to pass a note object?
What is the correct way to design this visual model? Basically for a "PerInstance" visual model it requires a model object to use it. Caliburn is a way to build it?
Caliburn is an interface (IHaveSubject and its Type Note & gt; PropertyChangedBase, IHasSubject & lt: Version IHaveSubject ) Addressing this type of scenario: This solution also integrates well with a pure ISubjectSpecification / conductor infrastructure. However after the creation of the post creation is a simple and effective solution, you may not want (design perspective) to leave a clear manufacturer parameter to viewModel istantiate note required to apply this case to me It seems that you have to take advantage of the specific characteristics of your di container, because you can have some parameters of the manufacturer representing a 'real' input parameter, while others can save The dependence can be. The castle in Windsor, for example, is a good feature that allows you to create a clear (type) factory for your view modal; The factory method will only allow "real" parameters to be set, while all dependencies are managed by the container (see this post for a detailed description of this Windsor feature):
class NoteViewModel: Basically it tipically permits a means to configure ViewModel with a "theme", after its instinct, through the container gives ; {...} myNoteViewModel = ... // Get an example of myNoteViewModel.WithwithSubject (new note ());