public string RegisterHarvester(List <string> arguments)
    {
        Harvester harvester = HarvesterFactory.CreateHarvester(arguments);

        this.harvesters.Add(harvester);
        return($"Successfully registered {harvester.GetType().Name.Replace("Harvester", "")} Harvester - {harvester.Id}");
    }
예제 #2
0
    public string RegisterHarvester(List <string> arguments)
    {
        try
        {
            var type              = arguments[0];
            var id                = arguments[1];
            var oreOutput         = double.Parse(arguments[2]);
            var energyRequirement = double.Parse(arguments[3]);

            if (type == "Sonic")
            {
                //factory that return harvester
                var sonicHarvesterFactory = new HarvesterFactory();
                var sonicFactor           = int.Parse(arguments[4]);
                var sonicHarvester        = sonicHarvesterFactory.GenerateSonicHarvester(id, oreOutput, energyRequirement, sonicFactor);
                //add to list
                harvesters.Add(sonicHarvester);
                return($"Successfully registered Sonic Harvester - {sonicHarvester.Id}");
            }
            // if type == Hammer
            var hammerHarvesterFactory = new HarvesterFactory();
            var hammerHarvester        = hammerHarvesterFactory.GenerateHammerHarvester(id, oreOutput, energyRequirement);
            //add to list
            harvesters.Add(hammerHarvester);
            return($"Successfully registered Hammer Harvester - {hammerHarvester.Id}");
        }
        catch (Exception e)
        {
            return($"Harvester is not registered, because of it's {e.Message}");
        }
    }
예제 #3
0
    public string RegisterHarvester(List <string> args)
    {
        string    type              = args[0];
        string    id                = args[1];
        double    oreOutput         = double.Parse(args[2]);
        double    energyRequirement = double.Parse(args[3]);
        Harvester harvester         = null;
        int       sonicFactor       = 0;
        string    result            = string.Empty;

        try
        {
            IOManager.IsRegisterHarvesterValid(type, id, oreOutput, energyRequirement, sonicFactor);

            if (type == "Sonic")
            {
                sonicFactor = int.Parse(args[4]);
            }

            harvester = HarvesterFactory.GetHarvester(type, id, oreOutput, energyRequirement, sonicFactor);
            result    = $"Successfully registered {type} Harvester - {id}";

            harvesters.Add(harvester);
        }
        catch (Exception e)
        {
            result = e.Message;
        }

        return(result);
    }
예제 #4
0
 public DraftManager()
 {
     this.harvesters       = new Dictionary <string, Harvester>();
     this.providers        = new Dictionary <string, Provider>();
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
 }
예제 #5
0
 public DraftManager()
 {
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
     this.harvesters       = new List <Harvester>();
     this.providers        = new List <Provider>();
 }
        public static ConDepExecutionResult ExecuteFromAssembly(ConDepSettings conDepSettings, CancellationToken token)
        {
            try
            {
                if (conDepSettings.Options.Assembly == null)
                {
                    throw new ArgumentException("assembly");
                }

                var lbLookup = new LoadBalancerLookup(conDepSettings.Config.LoadBalancer);
                var runbookConfigurationHandler = new RunbookConfigurationHandler(new RunbookHandler(), new RunbookDependencyHandler(), lbLookup.GetLoadBalancer());
                //var sequenceManager = artifactConfigHandler.CreateExecutionSequence(conDepSettings);

                var clientValidator = new ClientValidator();

                var serverInfoHarvester = HarvesterFactory.GetHarvester(conDepSettings);
                var serverValidator     = new RemoteServerValidator(conDepSettings.Config.Servers,
                                                                    serverInfoHarvester, new PowerShellExecutor());


                //if (conDepSettings.Options.DryRun)
                //{
                //    Logger.Warn("Showing execution sequence from dry run:");
                //    sequenceManager.DryRun(conDepSettings);
                //    return new ConDepExecutionResult(true);
                //}

                return(new ConDepConfigurationExecutor().Execute(conDepSettings, clientValidator, serverValidator, runbookConfigurationHandler.GetRunbooksToExecute(conDepSettings), new ServerHandler(), token));
            }
            catch (Exception ex)
            {
                Logger.Error("An error sneaked by.", ex);
                throw;
            }
        }
예제 #7
0
    public string RegisterHarvester(List <string> arguments)
    {
        var type              = arguments[0];
        var id                = arguments[1];
        var oreOutput         = double.Parse(arguments[2]);
        var energyRequirement = double.Parse(arguments[3]);
        var sonicFactor       = 0;

        if (arguments.Count == 5)
        {
            sonicFactor = int.Parse(arguments[4]);
        }

        try
        {
            var harvester = new HarvesterFactory();
            this.harvestersById.Add(id, harvester.GenerateHarvester(arguments));
        }
        catch (ArgumentException e)
        {
            return(e.Message);
        }

        return($"Successfully registered {type} Harvester - {id}");
    }
예제 #8
0
    public static void Main()
    {
        // Идеята на това решение е вземайки двата контролера HarvesterController и ProviderController
        // и вкарвайки ги като полета (един от тих илии двата) в командите,
        // ползвайки техните методи да достъпваме всичко необходимо ни в работата, вместо
        // да подавам евсички дипендънсита като полета на всяка команда!!!!!!!!!!!


        // Structure - 250/250; IO - error;
        IHarvesterFactory harvesterFactory = new HarvesterFactory();
        IProviderFactory  providerFactory  = new ProviderFactory();
        IEnergyRepository energyRepository = new EnergyRepository();
        // DraftManager manager = new DraftManager(harvesterFactory, providerFactory);

        //ICommandInterpreter commandInterpreter = new CommandInterpreter(harvesterFactory, providerFactory,
        //       repository, manager);
        IHarvesterController harvesterController = new HarvesterController(energyRepository, harvesterFactory);
        IProviderController  providerController  = new ProviderController(energyRepository);
        ICommandInterpreter  commandInterpreter  = new CommandInterpreter(harvesterController, providerController);

        IWriter writer = new Writer();
        IReader reader = new Reader();

        // Engine engine = new Engine(harvesterFactory, providerFactory, repository, commandInterpreter, writer, reader);
        Engine engine = new Engine(commandInterpreter, writer, reader);

        engine.Run();
    }
    public string RegisterHarvester(List <string> arguments)
    {
        try
        {
            var type              = arguments[0];
            var id                = arguments[1];
            var oreOutput         = double.Parse(arguments[2]);
            var energyRequirement = double.Parse(arguments[3]);

            switch (type)
            {
            case "Sonic":
                var sonicFactor = int.Parse(arguments[4]);
                this.harversters.Add(id, HarvesterFactory.CreateHarvester(type, id, oreOutput, energyRequirement, sonicFactor));
                break;

            case "Hammer":
                this.harversters.Add(id, HarvesterFactory.CreateHarvester(type, id, oreOutput, energyRequirement, 0));
                break;
            }

            return($"Successfully registered {type} Harvester - {id}");
        }
        catch (ArgumentException ae)
        {
            return(ae.Message);
        }
    }
예제 #10
0
 public DraftManager(HarvesterFactory harvesterFactory, ProviderFactory providerFactory)
 {
     this.harvesters       = new List <Harvester>();
     this.providers        = new List <Provider>();
     this.harvesterFactory = harvesterFactory;
     this.providerFactory  = providerFactory;
     this.mode             = "Full";
 }
예제 #11
0
 public DraftManager()
 {
     mode             = "Full";
     Harvesters       = new List <Harvester>();
     Providers        = new List <Provider>();
     providerFactory  = new ProviderFactory();
     harvesterFactory = new HarvesterFactory();
 }
예제 #12
0
 public DraftManager(HarvesterFactory harvesterFactory, ProviderFactory providerFactory)
 {
     this.harvesterFactory = harvesterFactory;
     this.providerFactory  = providerFactory;
     this.harvesters       = new Dictionary <string, IHarvester>();
     this.providers        = new Dictionary <string, IProvider>();
     this.mode             = "Full";
 }
예제 #13
0
 public DraftManager()
 {
     this.currentMode      = "Full";
     this.harvesters       = new List <Harvester>();
     this.providers        = new List <Provider>();
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
 }
예제 #14
0
 public DraftManager()
 {
     this.harvesterFactory = new HarvesterFactory();
     this.providers        = new Dictionary <string, Provider>();
     this.harvesters       = new Dictionary <string, Harvester>();
     this.providerFactory  = new ProviderFactory();
     this.mode             = global::Mode.Full;
 }
예제 #15
0
 public DraftManager()
 {
     this.Harvesters       = new List <Harvester>();
     this.Providers        = new List <Provider>();
     this.mode             = "Full";
     this.HarvesterFactory = new HarvesterFactory();
     this.ProviderFactory  = new ProviderFactory();
 }
예제 #16
0
    public static void Main()
    {
        var harvesterFactory = new HarvesterFactory();
        var providerFactory  = new ProviderFactory();
        var draftManager     = new DraftManager(harvesterFactory, providerFactory);
        var engine           = new Engine(draftManager);

        engine.Run();
    }
예제 #17
0
 public DraftManager()
 {
     this.currentMode      = "Full";
     this.modelsById       = new Dictionary <string, BaseModel>();
     this.harvestersById   = new Dictionary <string, Harvester>();
     this.providersById    = new Dictionary <string, Provider>();
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
 }
예제 #18
0
    public string RegisterHarvester(List <string> arguments)
    {
        var harvesterFactory = new HarvesterFactory();
        var harvester        = harvesterFactory.CreateHarvester(arguments);

        this.harvesters.Add(harvester);

        return($"Successfully registered {arguments[0]} Harvester - {harvester.Id}");
    }
예제 #19
0
 public DraftManager()
 {
     this.workingMode      = WorkingMode.Full;
     this.harvesters       = new List <Harvester>();
     this.providers        = new List <Provider>();
     this.harvesterFactory = new HarvesterFactory();
     this.providerFactory  = new ProviderFactory();
     this.byId             = new Dictionary <string, Unit>();
 }
 public DraftManager()
 {
     this.harvesters        = new List <Harvester>();
     this.providers         = new List <Provider>();
     this.harvesterFactory  = new HarvesterFactory();
     this.providerFactory   = new ProviderFactory();
     this.mode              = "Full";
     this.totalEnergyStored = 0;
     this.totalMinedOre     = 0;
 }
 public DraftManager()
 {
     this.allProviders      = new List <Provider>();
     this.allHarvesters     = new List <Harvester>();
     this.providerFactory   = new ProviderFactory();
     this.harvesterFactory  = new HarvesterFactory();
     this.currentMode       = "Full";
     this.totalMinedOre     = 0;
     this.totalStoredEnergy = 0;
 }
예제 #22
0
 public DraftManager()
 {
     this.mode        = "Full";
     this.oreOut      = 0;
     this.energi      = 0;
     this.harvesters  = new List <Harvester>();
     this.providers   = new List <Provider>();
     providerFactory  = new ProviderFactory();
     harvesterFactory = new HarvesterFactory();
 }
예제 #23
0
 public DraftManager()
 {
     harvesterFactory  = new HarvesterFactory();
     providerFactory   = new ProviderFactory();
     harvesters        = new List <Harvester>();
     providers         = new List <Provider>();
     mode              = "full";
     totalEnergyStored = 0;
     totalMinedOre     = 0;
 }
 public DraftManager()
 {
     totalEnergyStored  = 0;
     totalOreMined      = 0;
     systemMode         = "Full";
     this.allHarvesters = new List <Harvester>();
     this.allProviders  = new List <Provider>();
     harvFact           = new HarvesterFactory();
     provFact           = new ProviderFactory();
 }
예제 #25
0
 public DraftManager()
 {
     this.harvesters        = new Dictionary <string, IHarvester>();
     this.providers         = new Dictionary <string, IProvider>();
     this.mode              = "Full";
     this.totalEnergyStored = 0;
     this.totalMinedOre     = 0;
     this.creatProvider     = new ProviderFactory();
     this.createHarvester   = new HarvesterFactory();
 }
예제 #26
0
 public DraftManager()
 {
     _harvesters        = new List <Harvester>();
     _providers         = new List <Provider>();
     _harvesterFactory  = new HarvesterFactory();
     _providerFactory   = new ProviderFactory();
     _currentMode       = global::MinedraftApp.Enums.Mode.Full;
     _totalStoredEnergy = 0d;
     _totalStoredEnergy = 0d;
 }
예제 #27
0
 public DraftManager()
 {
     this.registeredHarvesters = new List <Harvester>();
     this.registeredProviders  = new List <Provider>();
     this.harvesterFactory     = new HarvesterFactory();
     this.providerFactory      = new ProviderFactory();
     this.systemMode           = "Full Mode";
     this.totalStoredEnergy    = 0;
     this.totalMinedOre        = 0;
 }
예제 #28
0
 public DraftManager()
 {
     _harvesters        = new List <Harvester>();
     _providers         = new List <Provider>();
     _harvesterFactory  = new HarvesterFactory();
     _providerFactory   = new ProviderFactory();
     _mode              = "Full";
     _totalEnergyStored = 0;
     _totalMinedOre     = 0;
 }
예제 #29
0
 public DraftManager()
 {
     harvesterFactory       = new HarvesterFactory();
     providerFactory        = new ProviderFactory();
     harvesters             = new Dictionary <string, Harvester>();
     providers              = new Dictionary <string, Provider>();
     this.totalMinedOre     = 0;
     this.totalEnergyStored = 0;
     this.mode              = "Full";
 }
예제 #30
0
 public DraftManager()
 {
     this.harvesters        = new List <Harvester>();
     this.providers         = new List <Provider>();
     this.harvesterFactory  = new HarvesterFactory();
     this.providerFactory   = new ProviderFactory();
     this.currentMode       = global::Mode.Full;
     this.totalStoredEnergy = 0d;
     totalStoredEnergy      = 0d;
 }