Skip to main content
5 events
when toggle format what by license comment
Oct 2, 2017 at 15:58 comment added Mathieu Guindon I'm seriously considering putting that cleanup on hold until Castle Windsor port is finished, and then go with full-on property injection using a naming convention on the command properties; that way I remove all constructor injection, have no need for attributes, the properties can be exposed to XAML as the ICommand interface they need to be, and the only problem becomes documenting how these magic properties get assigned.
Oct 2, 2017 at 15:53 comment added CharlesNRice The other option is to constructor inject all the commands in the t4 template and assign them instead of using linq. If that makes it more palatable to you. Since it's a t4 template it would do the hard work of adding all the classes into the constructor.
Oct 2, 2017 at 15:52 comment added CharlesNRice Exactly. Unfortunately DI containers don't have a good way to know the difference between classes with the same interface. Unity has a string you can pass in to it to resolve a specific type but again I wouldn't want that in my VM and would prefer to keep ugly code in one spot and not have all my WM have ugly code. Maybe one day there can be a better solution and then you just need to replace one class an not change all the VM. Even the other answer is just like a kernel resolver as well.
Oct 2, 2017 at 15:47 comment added Mathieu Guindon In other words, move the ugliness into another class, and have the redundant LINQ code generated by a t4 template. Interesting approach, but IMO just moves the problem elsewhere - that generated class now has the constructor injection and command sorting-out responsibility, and the CommandManager becomes some sort of command locator. I'd even name it as such.
Oct 2, 2017 at 14:56 history answered CharlesNRice CC BY-SA 3.0