/// <summary> /// Registers a service that is always resolved as lazy wrapper. /// </summary> /// <typeparam name="TInterface">The type of the interface.</typeparam> /// <typeparam name="TClass">The type of the class.</typeparam> /// <param name="registrator">The registrator.</param> /// <param name="serviceKey">Optional service key.</param> public static IRegistrator RegisterAsLazy <TInterface, TClass>(this IRegistrator registrator, object serviceKey = null) where TInterface : class where TClass : TInterface { // perform normal registration registrator.Register <TInterface, TClass>(serviceKey: serviceKey); // register the interface for lazy interception return(registrator.ResolveAsLazy <TInterface>(serviceKey)); }
/// <summary> /// Ensures that a service always resolves as lazy proxy. /// </summary> /// <typeparam name="TInterface">The type of the interface.</typeparam> /// <param name="registrator">The registrator.</param> /// <param name="serviceKey">Optional service key.</param> public static IRegistrator ResolveAsLazy <TInterface>(this IRegistrator registrator, object serviceKey = null) where TInterface : class { return(registrator.ResolveAsLazy(typeof(TInterface), serviceKey)); }