public ServiceDefinitionBuilder Service(Type implementationType)
        {
            var existingServiceDefinition = Model.FindServiceByImplementation(implementationType);

            if (existingServiceDefinition != null)
            {
                if (existingServiceDefinition.Type != ServiceType.Local)
                {
                    throw new InvalidOperationException($"The service '{existingServiceDefinition.Name}' is already defined as '{existingServiceDefinition.Type}' and should not be re-defined as '{ServiceType.Local}'. Use a different builder method.");
                }
                return(new ServiceDefinitionBuilder((IMutableServiceDefinition)existingServiceDefinition));
            }

            var serviceDefinition = new ServiceDefinition((CommunicationModel)Model);

            serviceDefinition.Type           = ServiceType.Local;
            serviceDefinition.Implementation = implementationType;

            var generatedServiceName = DefaultServiceNamer.GetServiceNameFromType(implementationType);

            if (Model.FindServiceByName(generatedServiceName) == null)
            {
                serviceDefinition.Name = generatedServiceName;
            }

            var defaultInterfaceType = DefaultServiceInterfaceFinder.FindDefaultInterface(implementationType);

            if (defaultInterfaceType != null && Model.FindServiceByInterface(defaultInterfaceType) == null)
            {
                serviceDefinition.AddInterface(defaultInterfaceType);
            }

            return(ServiceDefinitionBuilder.CreateByImplementationType(implementationType, serviceDefinition));
        }
        public ServiceDefinitionBuilder Service(Type interfaceType, Type implementationType)
        {
            var existingServiceDefinition = Model.FindServiceByInterface(interfaceType);

            if (existingServiceDefinition != null)
            {
                if (existingServiceDefinition.Type != ServiceType.Local)
                {
                    throw new InvalidOperationException($"The service '{existingServiceDefinition.Name}' is already defined as '{existingServiceDefinition.Type}' and should not be re-defined as '{ServiceType.Local}'. Use a different builder method.");
                }
                return(ServiceDefinitionBuilder.CreateByImplementationType(implementationType, (IMutableServiceDefinition)existingServiceDefinition));
            }

            var serviceDefinitionBuilder = Service(implementationType);

            serviceDefinitionBuilder.ServiceDefinition.AddInterface(interfaceType);
            return(serviceDefinitionBuilder);
        }