/// <summary> /// Call this method from the constructor of a class derived from <see cref="DbConfiguration" /> to /// add a <see cref="IDbDependencyResolver" /> instance to the Chain of Responsibility of resolvers that /// are used to resolve dependencies needed by the Entity Framework. /// </summary> /// <remarks> /// Resolvers are asked to resolve dependencies in reverse order from which they are added. This means /// that a resolver can be added to override resolution of a dependency that would already have been /// resolved in a different way. /// The only exception to this is that any dependency registered in the application's config file /// will always be used in preference to using a dependency resolver added here. /// </remarks> /// <param name="resolver"> The resolver to add. </param> protected internal void AddDependencyResolver(IDbDependencyResolver resolver) { Check.NotNull(resolver, "resolver"); _internalConfiguration.CheckNotLocked("AddDependencyResolver"); _internalConfiguration.AddDependencyResolver(resolver); }
/// <summary> /// Call this method to add a <see cref="IDbDependencyResolver" /> instance to the Chain of /// Responsibility of resolvers that are used to resolve dependencies needed by the Entity Framework. /// </summary> /// <remarks> /// Resolvers are asked to resolve dependencies in reverse order from which they are added. This means /// that a resolver can be added to override resolution of a dependency that would already have been /// resolved in a different way. /// The only exception to this is that any dependency registered in the application's config file /// will always be used in preference to using a dependency resolver added here, unless the /// overrideConfigFile is set to true in which case the resolver added here will also override config /// file settings. /// </remarks> /// <param name="resolver"> The resolver to add. </param> /// <param name="overrideConfigFile">If true, then the resolver added will take precedence over settings in the config file.</param> public void AddDependencyResolver(IDbDependencyResolver resolver, bool overrideConfigFile) { Check.NotNull(resolver, "resolver"); _internalConfiguration.CheckNotLocked("AddDependencyResolver"); _internalConfiguration.AddDependencyResolver(resolver, overrideConfigFile); }
public void SwitchInRootResolver_leaves_other_resolvers_intact() { var configuration = new InternalConfiguration(); var mockResolver = new Mock <IDbDependencyResolver>(); configuration.AddDependencyResolver(mockResolver.Object); configuration.SwitchInRootResolver(new Mock <RootDependencyResolver>().Object); configuration.DependencyResolver.GetService <object>("Foo"); mockResolver.Verify(m => m.GetService(typeof(object), "Foo")); }