/// <summary> /// Implements the <see cref="IContainerConfig.Configure(Container, IRootTargetContainer)"/> method, /// registering all the targets necessary to use expression-based compilation for all the standard targets /// defined in the <c>Rezolver</c> core library. /// </summary> /// <param name="container">The container - ignored.</param> /// <param name="targets">Required - the target container into which the various targets will be registered.</param> /// <remarks>All targets registered by this function are <see cref="ObjectTarget"/> targets backed by concrete instances /// of the various components (compiler etc).</remarks> public virtual void Configure(Container container, IRootTargetContainer targets) { if (targets == null) { throw new ArgumentNullException(nameof(targets)); } // note - the singleton container is done like this because the expression compiler which uses // it Resolves it from the container during compilation. This is to ensure that each container // gets the same singleton container (including OverridingContainer), rather than a single shared one // from the target container option. targets.RegisterObject(new SingletonTarget.SingletonContainer()); // targets.RegisterObject(new ExpressionBuilderCache(container)); // will be how containers pick up and use this compiler targets.SetOption <ITargetCompiler>(ExpressionCompiler.Default); // if you're looking to re-enter the compilation process for a particular // target - then you should request our compiler via the type IExpressionCompiler targets.SetOption <IExpressionCompiler>(ExpressionCompiler.Default); // loop through all the types in the core Rezolver assembly's Rezolver.Targets namespace, searching for an implementing // type in this assembly foreach (var registration in GetStandardTargetBuilders()) { targets.SetOption(registration.Instance, registration.TargetType); } }
public override void Configure(IRootTargetContainer targets) { _verify(targets); targets.RegisterObject(this); }