-
-
Save NatMarchand/79a80651b47742ed42e6782c9f6ff847 to your computer and use it in GitHub Desktop.
webformdependencyinjection_autofac2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Linq; | |
using Autofac.Builder; | |
using Autofac.Core; | |
namespace Autofac.Integration.Web | |
{ | |
public class WebFormRegistrationSource : IRegistrationSource | |
{ | |
public IEnumerable<IComponentRegistration> RegistrationsFor(Service service, Func<Service, IEnumerable<IComponentRegistration>> registrationAccessor) | |
{ | |
if (service is IServiceWithType serviceWithType && serviceWithType.ServiceType.Namespace.StartsWith("ASP", true, CultureInfo.InvariantCulture)) | |
{ | |
return new[] | |
{ | |
RegistrationBuilder.ForType(serviceWithType.ServiceType).CreateRegistration() | |
}; | |
} | |
return Enumerable.Empty<IComponentRegistration>(); | |
} | |
public bool IsAdapterForIndividualComponents => true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment