Versions Compared

Key

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

...

In every object, it is possible to use the Default properties to retrieve the instances of each component. This will cause problems when different scoping is used. To always be sure to get the right component for the object you are working with, it is recommended to use the following extension methods:

Code Block
using Catel.IoC; // Contains ObjectExtensions which allow use of below extension methods

public class MyService
{
    public void SomeMethod()
	{
        // If you need to create a type with the current scope type factory
		var typeFactory = this.GetTypeFactory();
 
        // If you need to register a type with the current scope service locator
        var serviceLocator = this.GetServiceLocator();
 
        // If you need to resolve a type with the current scope and the type is not injected via dependency injection
        var dependencyResolver = this.GetDependencyResolver();
	}
}