public object Execute() { if (_executed) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ComponentActivationResources.ActivationAlreadyExecuted, this.ComponentRegistration)); } _executed = true; object?decoratorTarget = null; var sharing = _decoratorTargetComponent != null ? _decoratorTargetComponent.Sharing : ComponentRegistration.Sharing; var resolveParameters = Parameters as Parameter[] ?? Parameters.ToArray(); if (!_activationScope.TryGetSharedInstance(ComponentRegistration.Id, out _newInstance)) { _newInstance = sharing == InstanceSharing.Shared ? _activationScope.CreateSharedInstance(ComponentRegistration.Id, () => CreateInstance(Parameters)) : CreateInstance(Parameters); } decoratorTarget = _newInstance; _newInstance = InstanceDecorator.TryDecorateRegistration( _service, ComponentRegistration, _newInstance, _activationScope, resolveParameters); if (_newInstance != decoratorTarget) { ComponentRegistration.RaiseActivating(this, resolveParameters, ref _newInstance); } var handler = InstanceLookupEnding; handler?.Invoke(this, new InstanceLookupEndingEventArgs(this, NewInstanceActivated)); StartStartableComponent(decoratorTarget); return(_newInstance); }