コード例 #1
0
 private LifetimeDescriptor ChooseLifeTime(IContainerContext containerContext, RegistrationContext registrationContext) => registrationContext.IsWireUp
         ? Lifetimes.Singleton
         : registrationContext.Lifetime ?? containerContext.ContainerConfiguration.DefaultLifetime;
コード例 #2
0
 public DecoratorRegistrationContext(RegistrationContext registrationContext, IServiceRegistrator serviceRegistrator)
 {
     this.registrationContext = registrationContext;
     this.serviceRegistrator  = serviceRegistrator;
 }
コード例 #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 });
        }