Esempio n. 1
0
 private LifetimeDescriptor ChooseLifeTime(IContainerContext containerContext, RegistrationContext registrationContext) => registrationContext.IsWireUp
         ? Lifetimes.Singleton
         : registrationContext.Lifetime ?? containerContext.ContainerConfiguration.DefaultLifetime;
Esempio n. 2
0
 public DecoratorRegistrationContext(RegistrationContext registrationContext, IServiceRegistrator serviceRegistrator)
 {
     this.registrationContext = registrationContext;
     this.serviceRegistrator  = serviceRegistrator;
 }
Esempio n. 3
0
        private void PreProcessExistingInstanceIfNeeded(IContainerContext containerContext, RegistrationContext registrationContext, Type implementationType)
        {
            if (registrationContext.ExistingInstance == null)
            {
                return;
            }

            if (!registrationContext.IsLifetimeExternallyOwned && implementationType.IsDisposable())
            {
                containerContext.RootScope.AddDisposableTracking(registrationContext.ExistingInstance);
            }

            if (registrationContext.Finalizer == null)
            {
                return;
            }

            var method = Constants.AddWithFinalizerMethod.MakeGenericMethod(implementationType);

            method.Invoke(containerContext.RootScope, new[] { registrationContext.ExistingInstance, registrationContext.Finalizer });
        }