/// <summary> /// RegisterInstance the container itself for service locator reasons. /// </summary> private void RegisterContainer() { var typeOfIContainer = typeof(IContainer); // The container is already registered from external. if (_registrationContainer.HasRegistration(typeOfIContainer)) { _registrationContainer.RemoveRegistration(typeOfIContainer); } var registrationItem = new RegistrationItem(typeOfIContainer) { Activator = new InstanceActivator <IContainer>(this), Lifecycle = new TransientLifecycle() }; _registrationContainer.AddRegistration(registrationItem); }
/// <summary> /// Add a registrationItem to the registrations. /// </summary> /// <param name="registrationItem">The registration to add.</param> private IFluentRegistration AddToRegistrationFluent(RegistrationItem registrationItem) { Action registrationCallback = () => { // Set default reuse scope, if not user defined. (System default is <see cref="TransientLifecycle" />. if (registrationItem.Lifecycle == null) { registrationItem.Lifecycle = this._defaultLifecycleFunction(); } if (_activeRegistrationGroupsInternal != null && registrationItem.Group != null) { if ( !this._activeRegistrationGroupsInternal.Any( g => g.Trim() == registrationItem.Group.Trim())) { // Do not add inactive registrationItem. return; } } if (_activeRegistrationGroupsInternal == null && registrationItem.Group != null) { // Do not add inactive registrationItem. return; } _registrationContainer.AddRegistration(registrationItem); }; _registrationCallbacks.Add(registrationCallback); // Return a new instance of <see cref="IFluentRegistration" /> for supporting a fluent interface for registration configuration. return(new FluentRegistration(registrationItem)); }