public void Outputter_Setup() { _uutOutputter = new AirTrafficOutputter(); _airspace = FakeAirspaceGenerator.GetAirspace(100, 100, 100); _logFile = "../../Test.txt"; }
public override void Execute(IOutputter outputter) { List <FileSystemItem> content = dirToPrint.Content; outputter.PrintLine("Directory of " + dirToPrint.Path); outputter.NewLine(); foreach (FileSystemItem item in content) { if (item.IsDirectory()) { outputter.Print("<DIR>"); } else { outputter.Print("" + item.GetSize()); } outputter.Print("\t" + item.Name); outputter.NewLine(); } outputter.PrintLine("\t" + dirToPrint.GetNumberOfFiles() + " File(s)"); outputter.PrintLine("\t" + dirToPrint.GetNumberOfDirectories() + " Dir(s)"); }
protected override bool CheckParameterValues(IOutputter outputter) { if (GetParameters().Count > 0) { string dirPath = GetParameters()[0]; FileSystemItem fs = Drive.GetItemFromPath(dirPath); if (fs == null) { outputter.PrintLine("File Not Found"); return(false); } if (fs.IsDirectory() == false) { dirToPrint = fs.Parent; } else { dirToPrint = (Directory)fs; } } else { dirToPrint = Drive.CurrentDirectory; } return(true); }
/// <summary> /// Initialise a new instance of the GeneticEngine class with the supplied plug-ins and populate the initial generation. /// </summary> /// <param name="populator">The populator plug-in. Generates the initial population.</param> /// <param name="evaluator">The evaluator plug-in. Provides the fitness function.</param> /// <param name="geneticOperator">The genetic operator plug-in. Processes one generation to produce the individuals for the next.</param> /// <param name="terminator">The terminator plug-in. Provides the termination condition.</param> /// <param name="outputter">The outputter plug-in or null for no output. Outputs each generation.</param> /// <param name="generationFactory">The generation factory plug-in or null to use the default. Creates the generation container.</param> public GeneticEngine(IPopulator populator, IEvaluator evaluator, IGeneticOperator geneticOperator, ITerminator terminator, IOutputter outputter = null, IGenerationFactory generationFactory = null) { if (populator == null) { throw new GeneticEngineException("populator must not be null"); } if (evaluator == null) { throw new GeneticEngineException("pvaluator must not be null"); } if (geneticOperator == null) { throw new GeneticEngineException("geneticOperator must not be null"); } if (terminator == null) { throw new GeneticEngineException("terminator must not be null"); } this.populator = populator; this.evaluator = evaluator; this.geneticOperator = geneticOperator; this.terminator = terminator; this.outputter = outputter; this.generationFactory = generationFactory == null ? new AATreeGenerationFactory() : generationFactory; Setup(); }
public override void Execute(IOutputter outputter) { for (int i = 0; i < GetParameterCount(); i++) { CreateDirectory(GetParameterAt(i), this.Drive); } }
public StubberManager(IOptions <StubberOption> options, IProcessor processor, IOutputter outputter) { _config = options.Value; IsRecording = false; _processor = processor; _outputter = outputter; }
public Game(IOutputter outputter, string playerName, Computer computer) { this.history = new List <RoundResult>(); this.player = new Player(playerName); this.computer = computer; _outputter = outputter; }
public override void Execute(IOutputter outputter) { if (GetParameterCount() > 0) { string fileName = GetParameterAt(0); string fileContent = GetContent(fileName, Drive.CurrentDirectory); string timeStamp = GetTimeStamp(fileName, Drive.CurrentDirectory); if (GetParameterCount() == 3 && GetParameterAt(2).Equals("/y", StringComparison.InvariantCultureIgnoreCase)) { File DelFile = new File(fileName, null, null); this.destinationDirectory.Del(DelFile); File CopyFile = new File(fileName, fileContent, timeStamp); this.destinationDirectory.Add(CopyFile, true); outputter.Print("Copy File " + fileName + " is Succeed Replace"); outputter.NewLine(); } else { File CopyFile = new File(fileName, fileContent, timeStamp); this.destinationDirectory.Add(CopyFile, false); outputter.Print("Copy File " + fileName + " is Succeed"); outputter.NewLine(); } } else { outputter.PrintLine(VER_IS_INVALID); } }
public Appearance(IOutputter outputter, IReadOnlyList <CProperty> appearanceProps) : base(null, outputter) { properties = appearanceProps.ToList(); // Create any properties that aren't guaranteed to exist (some DLCs added more properties) if (TorsoDeco == null) { properties.Add(NameProperty.Create("nmTorsoDeco")); } if (LeftForearm == null) { properties.Add(NameProperty.Create("nmLeftForearm")); } if (RightForearm == null) { properties.Add(NameProperty.Create("nmRightForearm")); } if (LeftArmDeco == null) { properties.Add(NameProperty.Create("nmLeftArmDeco")); } if (RightArmDeco == null) { properties.Add(NameProperty.Create("nmRightArmDeco")); } if (Thighs == null) { properties.Add(NameProperty.Create("nmThighs")); } }
private static void Day05_A() { const string defaultFilename = @"TEST_diagnostic.txt"; try { string fullFilename = Path.Combine(Environment.CurrentDirectory, "Day05", defaultFilename); Console.WriteLine(); Console.WriteLine($"Loading IntCode data from '{fullFilename}'..."); Console.WriteLine(); var factory = new Factory(); IInputter inputter = factory.CreateAutoInputter(1); IOutputter outputter = factory.CreateConsoleOutputter(); var intCodeComputer = factory.CreateIntCodeComputerFromFile(fullFilename, inputter, outputter); Console.WriteLine( $"There are #{intCodeComputer.InitialIntCodes.Count} Op codes in this IntCode program."); Console.WriteLine(); var finalOpCodes = intCodeComputer.Run(); Console.WriteLine( $"The value left at position 0 is '{finalOpCodes[0]}' after running the IntCode program."); Console.WriteLine(); Console.WriteLine(); Console.WriteLine( $"The last value outputted during the diagnosis of TEST is '{intCodeComputer.Outputter.OutputValues.Last()}'."); } catch (Exception ex) { Console.WriteLine($"An error occured '{ex.Message}'.{Environment.NewLine}Details: '{ex}'"); } }
public GameController GetGameController(IOutputter outputter) { var randomiser = new Randomiser(new System.Random()); var scheduleController = new ScheduleController(); var renderController = new RenderController(outputter); var inputController = new InputController(); var saveController = new SaveController(); var levelController = new LevelController(); var levelFactory = new LevelFactory(randomiser); var itemFactory = new ItemFactory(); var stringFormatter = new StringFormatterSmartFormat(); var assetBank = new AssetBank(stringFormatter); var eventBus = new EventBus(); var eventKeeper = new EventKeeper(eventBus, assetBank); var screenFactory = new ScreenFactory(eventKeeper); var playerFactory = new PlayerFactory(levelController, eventBus, randomiser, scheduleController); var enemyFactory = new EnemyFactory(eventBus, randomiser, scheduleController); return(new GameController( renderController, inputController, saveController, levelController, levelFactory, itemFactory, screenFactory, playerFactory, enemyFactory, eventBus, scheduleController )); }
/// <summary> /// Interprets a command string, executes if an appropriate command is found /// and returns all output via the outputter interface. /// </summary> /// <param name="command">string which is entered, containing the command and the parameters.</param> /// <param name="outputter">Implementation of the outputter interface to which the output text is sent.</param> public void ExecuteCommand(string command, IOutputter outputter) { string cmdName = ParseCommandName(command); List <string> parameters = ParseCommandParameters(command); try { foreach (DosCommand cmd in commands) { if (cmd.CompareCommandName(cmdName)) { cmd.SetParameters(parameters); if (cmd.CheckParameters(outputter)) { cmd.Execute(outputter); } return; } } outputter.PrintLine("\'" + cmdName + "\' is not recognized as an internal or external command,"); outputter.PrintLine("operable program or batch file."); } catch (Exception e) { outputter.PrintLine(e.Message); } }
private static void InitializeApplication() { ReadConfigurationFile(); _inputter = new ConsoleInputter(); _outputter = new ConsoleOutputter(); _printer = new Printer(_outputter); }
// Private constructor used for cloning private Character(IOutputter outputter, Character fromCharacter) : base(null, outputter) { ID = fromCharacter.ID; properties = fromCharacter.Properties.Select(p => p.Clone()).ToList(); Appearance = new Appearance(outputter, _appearance.Properties.Properties); IsDirty = fromCharacter.IsDirty; }
public override void Execute(IOutputter outputter) { if (GetParameterCount() > 0) { if (GetParameterCount() == 1 && GetParameterAt(0).Equals("/w", StringComparison.InvariantCultureIgnoreCase)) { outputter.PrintLine("Microsoft Windows XP [Versi 5.1.2600]"); outputter.PrintLine("Igustiawan"); outputter.PrintLine("*****@*****.**"); //return true; } else { outputter.PrintLine(VER_IS_INVALID); //return false; } } else { outputter.PrintLine("Microsoft Windows XP [Versi 5.1.2600]"); //return true; } //return false; }
static void Main() { var serviceProvider = new ServiceCollection() .AddSingleton <IParser <string, long>, NumberParser>() .AddSingleton <IRulesEngine <long, string>, AmericanNumberFormatRulesEngine>() .AddSingleton <IRulesProcessor <long, string>, MultiThreadedRulesProcessor <long, string> >() .AddSingleton <IInputterDialogue <string>, ConsoleFileNameDialogue>() .AddSingleton <IInputter <string>, FileInputter>() .AddSingleton <IOutputter <string>, StdOutStringOutputter>() .BuildServiceProvider(); bool run = true; while (run) { try { IParser <string, long> parser = serviceProvider.GetService <IParser <string, long> >(); IList <long> numbersToConvert = parser.ParseInput(serviceProvider.GetService <IInputter <string> >().Get()); IRulesProcessor <long, string> rulesProcessor = serviceProvider.GetService <IRulesProcessor <long, string> >(); IList <string> wordsConverted = rulesProcessor.Process(numbersToConvert); IOutputter <string> outputter = serviceProvider.GetService <IOutputter <string> >(); outputter.Output(wordsConverted); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Run Again y/n?"); run = Console.ReadLine().ToLower() == "y" ? true : false; } }
/// <summary> /// Public constructor, where the formatter is hooked up /// to an outputter. /// </summary> /// <param name="output">The outputter to be used.</param> public TextileFormatter(IOutputter output) : base(output, typeof(States.ParagraphFormatterState)) { RegisterFormatterState <HeaderFormatterState>(); RegisterFormatterState <BlockQuoteFormatterState>(); RegisterFormatterState <ParagraphFormatterState>(); RegisterFormatterState <FootNoteFormatterState>(); RegisterFormatterState <OrderedListFormatterState>(); RegisterFormatterState <UnorderedListFormatterState>(); RegisterFormatterState <TableFormatterState>(); RegisterFormatterState <TableRowFormatterState>(); RegisterFormatterState <CodeFormatterState>(); RegisterFormatterState <PreFormatterState>(); RegisterFormatterState <PreCodeFormatterState>(); RegisterFormatterState <PreBlockFormatterState>(); RegisterFormatterState <NoTextileFormatterState>(); RegisterBlockModifier <NoTextileBlockModifier>(); RegisterBlockModifier <CodeBlockModifier>(); RegisterBlockModifier <PreBlockModifier>(); RegisterBlockModifier <HyperLinkBlockModifier>(); RegisterBlockModifier <ImageBlockModifier>(); RegisterBlockModifier <GlyphBlockModifier>(); RegisterBlockModifier <EmphasisPhraseBlockModifier>(); RegisterBlockModifier <StrongPhraseBlockModifier>(); RegisterBlockModifier <ItalicPhraseBlockModifier>(); RegisterBlockModifier <BoldPhraseBlockModifier>(); RegisterBlockModifier <CitePhraseBlockModifier>(); RegisterBlockModifier <DeletedPhraseBlockModifier>(); RegisterBlockModifier <InsertedPhraseBlockModifier>(); RegisterBlockModifier <SuperScriptPhraseBlockModifier>(); RegisterBlockModifier <SubScriptPhraseBlockModifier>(); RegisterBlockModifier <SpanPhraseBlockModifier>(); RegisterBlockModifier <FootNoteReferenceBlockModifier>(); }
public Character(Parser parser, IOutputter outputter) : base(parser, outputter) { ID = Guid.NewGuid(); GetProperties(); Appearance = new Appearance(outputter, _appearance.Properties.Properties); WriteDebug(1); }
public FileReverser(IOutputter outputter, IInput input, IInputValidator inputValidator, IOutputValidator outputValidator, IReverserImplementation reverserImplementation) { _outputter = outputter; _input = input; _inputValidator = inputValidator; _outputValidator = outputValidator; _reverserImplementation = reverserImplementation; }
public FileReverser(IOutputter outputter, IInput input, IInputValidator inputValidator, IOutputValidator outputValidator, IReverserImplementation reverserImplementation) { _outputter = outputter; _input = input; _inputValidator = inputValidator; _outputValidator = outputValidator; _reverserImplementation = reverserImplementation; }
public override void Execute(IOutputter outputter) { string fileName = GetParameterAt(0); string fileContent = GetParameterAt(1); File newFile = new File(fileName, fileContent); this.Drive.CurrentDirectory.Add(newFile); }
public void TestSetup() { _fakeValidator = Substitute.For <IValidateEvent>(); _fakeConditionDetector = Substitute.For <IConditionDetector>(); _fakeOutputter = Substitute.For <IOutputter>(); _fakeUpdater = Substitute.For <IUpdater <List <ITrack> > >(); _uutAirTrafficMonitor = new AirTrafficMonitor(_fakeValidator, _fakeConditionDetector, _fakeOutputter, _fakeUpdater); }
public void SetTrafficController() { _uutOutputter = new AirTrafficOutputter { TrafficController = new ConsoleAirTrafficController() }; Assert.IsInstanceOf <ConsoleAirTrafficController>(_uutOutputter.TrafficController); }
public override void Execute(IOutputter outputter) { foreach (string newDirName in GetParameters()) { var newDir = new Directory(newDirName); Drive.CurrentDirectory.Add(newDir); } }
public void SetLoggerTest() { _uutOutputter = new AirTrafficOutputter { Logger = new FileLogger() }; Assert.IsInstanceOf <FileLogger>(_uutOutputter.Logger); }
/// <summary> /// <b>Must be overwritten</b> by the concrete commands to implement the execution of the command. /// </summary> /// <param name="outputter">Must be used to output any text.</param> public override void Execute(IOutputter outputter) { string fileName = GetParameters()[0]; string fileContent = GetParameters()[1]; var newFile = new File(fileName, fileContent); Drive.CurrentDirectory.Add(newFile); }
protected override bool CheckParameterValues(IOutputter outputter) { if (GetParameters().Count > 0) { newDirectoryName = GetParameters()[0]; } return(true); }
private static bool ParameterContainsBacklashes(string parameter, IOutputter outputter) { // Do not allow "mkdir c:\temp\dir1" to keep the command simple if (parameter.Contains("\\") || parameter.Contains("/")) { outputter.PrintLine(PARAMETER_CONTAINS_BACKLASH); return(true); } return(false); }
internal ProgramImpl( IPluginHandler pluginHandler, IFileSystem fileSystem, IAssemblyFactory assemblyFactory, IOutputter outputter) { this.pluginHandler = pluginHandler; this.fileSystem = fileSystem; this.assemblyFactory = assemblyFactory; this.outputter = outputter; }
public AirTrafficMonitor(IValidateEvent validator, IConditionDetector conditionDetector, IOutputter outputter, IUpdater <List <ITrack> > updater) { _validator = validator; _validator.ValidationCompleteEventHandler += Update; _conditionDetector = conditionDetector; _conditionDetector.ConditionsHandler += ConditionDetector_ConditionsHandler; _outputter = outputter; _updater = updater; Airspace = new Airspace(); Conditions = new List <ConditionEventArgs>(); }
public override void Execute(IOutputter outputter) { if (GetParameterCount() == 0) { PrintCurrentDirectoryPath(this.Drive.CurrentDirectory.Path, outputter); } else { ChangeCurrentDirectory(this.destinationDirectory, this.Drive, outputter); } }
public override void Execute(IOutputter outputter) { string fileName = GetParameters()[0]; var dirToPrint = Drive.CurrentDirectory; var file = dirToPrint.Content.OfType <Filesystem.File>().Single(f => f.Name == fileName); var content = file.FileContent; outputter.PrintLine($"-- Content of {file.Name} --"); outputter.PrintLine(content); }
public HexStringProcessor(IOutputter outputter) { _outputter = outputter; }
public DisplayOutputter(RoadNetworkFinder mainWindow, IOutputter wrappedOutputter) { this.mainWindow = mainWindow; this.wrappedOutputter = wrappedOutputter; //Set wrappedOutputter }
/// <summary> ///Check if the plugins have been selected by the user, if not the revelant exceptions are thrown ///asking the user to make a choice. ///So, if the populator,evaluators, geneticOperator and terminator choices are not chosen, then ///error messages are displayed to alert the user, that the choices for these four plugins cannot be null. ///If the plugins are chosen, the engine object is created according to the user choices and it is initialised. ///Once the engine is initialised, the rest of the buttons on the interface are activated and the fitness values ///are displayed. /// </summary> private void initEngineButton_Click(object sender, EventArgs e) { if (!engineRunning) { SetEngineRunning(true); populator = null; evaluator = null; geneticOperator = null; terminator = null; outputter = null; generationFactory = null; string errorMsg = ""; if (cbPopulator.SelectedItem == null) errorMsg += "Populator must not be null\n"; else { string choice = getChoice(populators, cbPopulator); try { populator = (IPopulator)loader.GetInstance(choice, (object)tbMapFile.Text); } catch (GeneticEngineException exception) { MessageBox.Show(exception.Message); } } if (cbEvaluator.SelectedItem == null) errorMsg += "Evaluator must not be null\n"; else { string choice = getChoice(evaluators, cbEvaluator); try { evaluator = (IEvaluator)loader.GetInstance(choice, null); } catch (GeneticEngineException exception) { MessageBox.Show(exception.Message); } } if (cbGeneticOperator.SelectedItem == null) errorMsg += "Genetic Operator must not be null\n"; else { string choice = getChoice(geneticOperators, cbGeneticOperator); try { geneticOperator = (IGeneticOperator)loader.GetInstance(choice, null); } catch (GeneticEngineException exception) { MessageBox.Show(exception.Message); } } if (cbTerminator.SelectedItem == null) errorMsg += "Terminator must not be null\n"; else { string choice = getChoice(terminators, cbTerminator); if ((int)targetFitness.Value == 0) errorMsg += "Provide a target fitness value greater than 1 for the terminator plug-in\n"; else { try { terminator = (ITerminator)loader.GetInstance(choice, (object)(uint)targetFitness.Value); } catch (GeneticEngineException exception) { MessageBox.Show(exception.Message); } } } if (cbOutputter.SelectedItem != null) { string choice = getChoice(outputters, cbOutputter); if (choice != noOutputterString) { if (tbOutputFile.Text == "") { MessageBox.Show("Select an output file for the outputter\n"); } else { outputter = (IOutputter)loader.GetInstance(choice, (object)tbOutputFile.Text); } } } if (cbGenerationFactory.SelectedItem != null) { string choice = getChoice(generationFactories, cbGenerationFactory); if (choice != defaultGenerationFactoryString) { generationFactory = (IGenerationFactory)loader.GetInstance(choice, null); } } if (errorMsg != "") MessageBox.Show(errorMsg + "Please make sure you have selected a populator, evaluator, genetic operator and terminator and then try pressing the button again\n"); else { try { displayOutputter = new DisplayOutputter(this, outputter); engine = new GeneticEngine(populator, evaluator, geneticOperator, terminator, displayOutputter, generationFactory); hasInitialised = true; } catch (GeneticEngineException ex) { MessageBox.Show(ex.Message); } } SetEngineRunning(false); } }
public OutputHelper(IOutputter outputter) { this.outputter = outputter; this.hasOutputErrors = false; }
/// <summary> /// Public constructor, where the formatter is hooked up /// to an outputter. /// </summary> /// <param name="output">The outputter to be used.</param> public TextileFormatter(IOutputter output) { m_output = output; }
/// <summary> /// Utility method for formatting a text with a given outputter. /// </summary> /// <param name="input">The string to format</param> /// <param name="outputter">The IOutputter to use</param> public static void FormatString(string input, IOutputter outputter) { TextileFormatter f = new TextileFormatter(outputter); f.Format(input); }
public BuildContentTool(IOutputter outputter) { this.Output = new OutputHelper(outputter); }
/// <summary> /// Constructor /// </summary> /// <param name="outputter">IOutputter to use for the script</param> public CsrTool(IOutputter outputter) { this.output = new OutputHelper(outputter, CsrResources.ResourceManager); }