예제 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            var mowingMachine = new MowingMachine(TestTimer.Instance)
            {
                Orientation = "North",
                Position    = new Position()
                {
                    Length = 0,
                    Width  = 0
                }
            };

            services.AddSingleton(mowingMachine);

            var lawn = new Lawn()
            {
                Length = 5,
                Width  = 5
            };

            services.AddSingleton(lawn);

            var navigator = new Navigator(mowingMachine, lawn);

            navigator.StartNavigation();
            services.AddSingleton(navigator);

            var controllersAssembly = Assembly.Load(new AssemblyName("GardenGizmos.SLMM"));

            services.AddMvc()
            .AddApplicationPart(controllersAssembly)
            .AddControllersAsServices()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
예제 #2
0
        public void Execute(MowingMachine mowingMachine, Lawn lawn)
        {
            var position = mowingMachine.NextPositionInDirection();

            if (lawn.PositionWithinBounds(position))
            {
                mowingMachine.MoveTo(position);
            }
        }
예제 #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            var mowingMachine = new MowingMachine(new SleepTimer())
            {
                Position = new Position()
            };

            Configuration.GetSection("MowingMachine").Bind(mowingMachine);
            services.AddSingleton(mowingMachine);

            var lawn = new Lawn();

            Configuration.GetSection("Lawn").Bind(lawn);
            services.AddSingleton(lawn);

            var navigator = new Navigator(mowingMachine, lawn);

            navigator.StartNavigation();
            services.AddSingleton(navigator);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
예제 #4
0
 public void Execute(MowingMachine mowingMachine, Lawn lawn)
 {
     mowingMachine.TurnAntiClockwise();
 }
예제 #5
0
 public Navigator(MowingMachine mowingMachine, Lawn lawn)
 {
     _mowingMachine = mowingMachine;
     _lawn          = lawn;
 }