コード例 #1
0
        public override void Register(IServiceCollection services, Type implementation, ServiceRegistrationScope registrationScope)
        {
            var registrar = registrationScope.Registrar(services);

            registrar(implementation, implementation);
        }
コード例 #2
0
 public abstract void Register(IServiceCollection services, Type implementation, ServiceRegistrationScope registrationScope);
コード例 #3
0
        public override void Register(IServiceCollection services, Type implementation, ServiceRegistrationScope registrationScope)
        {
            var interfaces = implementation.GetInterfaces();

            if (!interfaces.Any())
            {
                throw new ArgumentException($"{implementation.Name} does not have any interfaces");
            }

            var registrar = registrationScope.Registrar(services);

            foreach (var @interface in interfaces)
            {
                registrar(@interface, implementation);
            }
        }
        public override void Register(IServiceCollection services, Type implementation, ServiceRegistrationScope registrationScope)
        {
            var firstInterface = implementation.GetInterfaces().FirstOrDefault();

            if (firstInterface == null)
            {
                throw new ArgumentException($"{implementation.Name} does not have any interfaces");
            }

            var registrar = registrationScope.Registrar(services);

            registrar(firstInterface, implementation);
        }