Esempio n. 1
0
        private static RegistrationInfo Add(this ContainerBuilder builder,
                                            Type serviceType,
                                            Type implementationType          = null,
                                            Func <IResolver, object> factory = null,
                                            object instance = null)
        {
            var info = new RegistrationInfo
            {
                ServiceType        = serviceType,
                ImplementationType = implementationType ?? serviceType,
                Factory            = factory,
                Instance           = instance
            };

            builder.Registrations.Add(info);
            return(info);
        }
Esempio n. 2
0
 public static RegistrationInfo As <TService>(this RegistrationInfo info)
 {
     Throw.IfImplementationIsNotAssignableToService(info.ImplementationType, typeof(TService));
     info.ServiceType = typeof(TService);
     return(info);
 }
Esempio n. 3
0
 public static RegistrationInfo InstancePerMatchingLifetimeScope(this RegistrationInfo info, object scopeName)
 {
     return(info.WithReuse(Reuse.ScopedTo(scopeName)));
 }
Esempio n. 4
0
 public static RegistrationInfo InstancePerOwned <TService>(this RegistrationInfo info)
 {
     return(info.WithReuse(Reuse.ScopedTo <Owned <TService> >()));
 }
Esempio n. 5
0
 public static RegistrationInfo SingleInstance(this RegistrationInfo info)
 {
     return(info.WithReuse(Reuse.Singleton));
 }
Esempio n. 6
0
 private static RegistrationInfo WithReuse(this RegistrationInfo info, IReuse reuse)
 {
     info.Reuse = reuse;
     return(info);
 }
Esempio n. 7
0
 /// Reuse.Singleton
 public static RegistrationInfo SingleInstance(this RegistrationInfo info) => info.WithReuse(Reuse.Singleton);