/// <summary> /// Initializes a new instance of the <see cref="ComponentAttribute" /> class, marking the decorated class as a /// component that will be available from the service locator / component container using the specified /// <paramref name="registerAs" /> type. /// </summary> /// <param name="registerAs">The type to use to register the decorated component.</param> /// <param name="lifecycle">The lifecycle of dependency</param> protected ComponentAttribute(Type[] registerAs, EDependencyLifecycle lifecycle) { Guard.That(registerAs).IsNotEmpty(); RegisterAs = registerAs; Lifecycle = lifecycle; }
private static ComponentRegistration <object> RegisterComponents(this ComponentRegistration <object> builder, EDependencyLifecycle lifecycle) { switch (lifecycle) { case EDependencyLifecycle.Singleton: builder.LifestyleSingleton(); break; default: throw new ArgumentOutOfRangeException(nameof(lifecycle), lifecycle, null); } return(builder); }
private static void RegisterComponents(this IRegistrationBuilder <object, ConcreteReflectionActivatorData, SingleRegistrationStyle> builder, EDependencyLifecycle lifecycle) { switch (lifecycle) { case EDependencyLifecycle.Singleton: builder.SingleInstance(); break; default: throw new ArgumentOutOfRangeException(nameof(lifecycle), lifecycle, null); } }