Exemple #1
0
        private string GetLifetimeManager(ContainerRegistration registration)
        {
            switch (registration.Lifetime)
            {
            case Constants.ContainerRegistrationEvent.SingletonLifetime:
                return(".SingleInstance()");

            case Constants.ContainerRegistrationEvent.PerServiceCallLifetime:
                return(".InstancePerRequest()");

            case Constants.ContainerRegistrationEvent.TransientLifetime:
                return(string.Empty);

            default:
                return(string.Empty);
            }
        }
Exemple #2
0
 private string GetRegistrationString(ContainerRegistration x)
 {
     return(x.InterfaceType != null
         ? $"{Environment.NewLine}            builder.RegisterType<{NormalizeNamespace(x.ConcreteType)}>().As<{NormalizeNamespace(x.InterfaceType)}>(){GetLifetimeManager(x)};"
         : $"{Environment.NewLine}            builder.RegisterType<{NormalizeNamespace(x.ConcreteType)}>(){GetLifetimeManager(x)};");
 }