/// <summary> Add the specified type <paramref name="factoryType" /> to the DI container as a factory that performs factory methods for creating objects. </summary>
        /// <param name="services"> A collection of DI container services. </param>
        /// <param name="factoryType"> Factory type. </param>
        /// <returns> Reference to the passed object <paramref name="services" /> to be able to call methods in a chain. </returns>
        public static IServiceCollection AddFactory(this IServiceCollection services, Type factoryType)
        {
            if (factoryType == null)
            {
                throw new ArgumentNullException(nameof(factoryType));
            }

            services.AddAdvancedOptions();
            services.TryAddSingleton(factoryType, FactoryGenerator.Generate(factoryType));
            return(services);
        }
Ejemplo n.º 2
0
        public string Get()
        {
            var cityGenerator = new CityGenerator();

            if (!cityGenerator.Generate())
            {
                return("Error");
            }

            var factoryGenerator = new FactoryGenerator();

            if (!factoryGenerator.Generate())
            {
                return("Error");
            }

            var utilityGenerator = new UtilityGenerator();

            if (!utilityGenerator.Generate())
            {
                return("Error");
            }

            var regionGenerator = new RegionGenerator();

            if (!regionGenerator.Generate())
            {
                return("Error");
            }

            var containerGenerator = new ContainerGenerator();

            if (!containerGenerator.Generate())
            {
                return("Error");
            }

            var tripGenerator = new TripGenerator();

            if (!tripGenerator.Generate())
            {
                return("Error");
            }

            return("Success");
        }