Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note

Note that the Catel team recommends using constructor injection over property injection. Property injection looks like a silver bullet, but is very tricky because:

1) It does not allow you to check for null values and store dependencies in private fields (when)?

2) Dependency Injection is just a technique. When using a constructor, you can force a user to provide the value and check the input. With property injection, you can only hope that the user will set them for you, there is no way to check this (unless that is some after constructor and dependency injection initialization routine. This is never the case if a user manually creates a type though.

To use property injection, simply decorate the properties of a class with theĀ Inject attribute. Below are several options:

...