public ComponentRegistration RegistrationFor(Service service)
        {
            #region Please implement the method to pass the test

            /*
             * This source has 2 properties: the genericService is used as the key to match the
             * service argument. And the implementorType is used to record the actual type used
             * to create instances.
             *
             * This method will try matching the constructed service to an non-constructed
             * generic type of genericService. If it is matched, then an concrete component
             * registration needed wll be invoked.
             */

            var serviceWithType = service as IServiceWithType;

            if (serviceWithType != null &&
                Equals(serviceWithType.ChangeType(serviceWithType.ServiceType.GetGenericTypeDefinition()), genericService) &&
                serviceWithType.ServiceType.IsConstructedGenericType)
            {
                var activator = new ReflectiveActivator(implementorType.MakeGenericType(serviceWithType.ServiceType.GenericTypeArguments));
                return(new ComponentRegistration(service, activator));
            }

            return(null);

            #endregion
        }
        public static IRegistrationBuilder RegisterType <T>(
            this ContainerBuilder cb)
        {
            #region Please modify the following code to pass the test

            /*
             * Since you have re-implement Register method, I am sure you can also
             * implement RegisterType method.
             */
            var service               = new TypedService(typeof(T));
            var activator             = new ReflectiveActivator(typeof(T));
            var componentRegistration = new ComponentRegistration(service, activator);
            return(cb.RegisterComponent(componentRegistration));

            #endregion
        }