public static TinyIoCContainer.RegisterOptions WithScopeFromRegistrationInfo(this TinyIoCContainer.RegisterOptions regOpts, DependencyRegistration registration) { if (regOpts == null) { throw new ArgumentNullException(nameof(regOpts)); } if (registration == null) { throw new ArgumentNullException(nameof(registration)); } switch (registration.Scope) { case DependencyScope.Singleton: regOpts.AsSingleton(); break; case DependencyScope.Thread: regOpts.AsPerRequestSingleton(); break; case DependencyScope.Transient: if (!registration.IsProviderRegistration) { regOpts.AsMultiInstance(); } break; } return(regOpts); }
public static TinyIoCContainer.RegisterOptions Life(this TinyIoCContainer.RegisterOptions registration, LifeStyle life) { if (life == LifeStyle.Singleton) { return(registration.AsSingleton()); } return(registration.AsMultiInstance()); }
public void AsMultiInstance() { Debug.Assert(_registerOptions != null); _registerOptions.AsMultiInstance(); }