concept Local Default in category dependency injection

appears as: Local Default, A Local Default
Dependency Injection

This is an excerpt from Manning's book Dependency Injection.

A Local Default is a default implementation of a Dependency that originates in the same module or layer.

public class ContainerOptions
{
    IConstructorResolutionBehavior resolutionBehavior =
        new DefaultConstructorResolutionBehavior();    #1  

    public IConstructorResolutionBehavior ConstructorResolutionBehavior
    {
        get
        {
            return this.resolutionBehavior;
        }
        set
        {
            if (value == null)    #2  
              throw new ArgumentNullException("value");

            if (this.Container.HasRegistrations)    #3  
            {
                throw new InvalidOperationException(
                    "The ConstructorResolutionBehav" +
                    "ior property cannot be changed" +
                    " after the first registration " +
                    "has been made to the container.";
            }

            this.resolutionBehavior = value;    #4  
        }
    }
}

#1   Assignment of the private resolutionBehavior field with the DefaultConstructorResolutionBehavior Local Default
#2   Guard Clause with null check
#3   Guard Clause with a variation of the discussed internal flag that ensures Popsicle immutability17 
#4   Stores the incoming Dependency in the private field, overriding the Local Default
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest