public Program(string[] args) { config = GetConfig(); ParseArgs(args); _lexParse = new LexParser(new ASTBuilder(new ExpressionHelper())); _referenceHandler = new ReferenceHandler(new ReferenceHelper(), !_shouldThrowExceptions); _typeChecker = new TypeChecker(new DeclarationHelper(), new NumberHelper(), new CommonOperatorHelper(), new TypeBooleanHelper(), new TypeSetHelper()); _interpreter = new Interpreter(new GenericHelper(), new FunctionHelper(), new IntegerHelper(), new RealHelper(), new InterpBooleanHelper(), new InterpreterSetHelper(), new ElementHelper(), new StringHelper(), new GraphHelper(), !_shouldThrowExceptions); _outputGenerator = _output == OutputLanguage.DOT ? (IOutputGenerator) new DotGenerator() : (IOutputGenerator) new GmlGenerator(); _fileGenerator = new FileGenerator(new FileHelper()); _exceptionPrinter = new ExceptionPrinter(); _fileReader = new FileReader(new FileHelper()); }
private static IOutputGenerator LoadOutputGenerator(CommandLineOptions options) { IOutputGenerator outputGenerator = null; var extensionAssemblyPath = options.ExtensionAssemblyPath; if (!string.IsNullOrEmpty(extensionAssemblyPath)) { var assembly = Assembly.LoadFrom(extensionAssemblyPath); foreach (var type in assembly.GetTypes()) { if ((typeof(IOutputGenerator)).IsAssignableFrom(type)) { outputGenerator = (IOutputGenerator)Activator.CreateInstance(type); } } } if (outputGenerator == null) { outputGenerator = new DefaultOutputGenerator(); } if (!string.IsNullOrWhiteSpace(options.OutputPath)) { outputGenerator.OutputPath = options.OutputPath; } return(outputGenerator); }
public void Remove(IOutputGenerator gen) { if (gen is IOutput outputGen) { Remove(outputGen); } if (gen is ILayered <object> layeredGen) { foreach (PerTypeData perTypeData in dict.Values) { List <IOutput> outputsToRemove = new List <IOutput>(); foreach (IOutput output in perTypeData.perOutputProducts.Keys) { if (output.Gen == gen) { outputsToRemove.Add(output); } } foreach (IOutput output in outputsToRemove) { perTypeData.perOutputProducts.Remove(output); } } } }
static void Main(string[] args) { #region ConfigureServices var services = new ServiceCollection() .AddLogging(builder => { builder.AddConsole(); builder.AddDebug(); }) .AddSingleton <IFileProcessor, FileProcessor>() .AddSingleton <IHelper, Helper>() .AddSingleton <IOutputGenerator, OutputGenerator>() .BuildServiceProvider(); #endregion #region ConfigureLogging var logger = services.GetService <ILoggerFactory>() .CreateLogger <Program>(); #endregion IFileProcessor processor = Factory.GetFileProcessor(services); IHelper helper = Factory.GetHelper(services); logger.LogDebug("Driver Report Generator [Start]"); try { Console.WriteLine("Enter File Path:"); var filePath = Console.ReadLine(); if (File.Exists(filePath)) { //Extract Customer Details from FilePath var customerData = processor.ExtractCustomerDataFromInputFile(filePath); //Retrieve Driver Info var drivers = helper.RetrieveDriverInfo(customerData.DriverInfo); //Capture Trip Info helper.CaptureTripInfo(customerData.TripInfo, drivers); //CalculateDuration based on Trips helper.CalculateDuration(drivers); //Generate Output in Console. IOutputGenerator outputGenerator = Factory.GetOutputGenerator(services); outputGenerator.PrintOutput(drivers); } else { throw new Exception($"File {filePath} not found or does not exists."); } } catch (global::System.Exception ex) { logger.LogError($"Unhandled Exception occured. Error Message: {ex.Message}", ex); } logger.LogDebug("Driver Report Generator [End]"); }
public void BeforeEachTest() { _writerMock = new Mock <TextWriter>(MockBehavior.Strict); _optionsMock = new Mock <IOptions>(MockBehavior.Strict); _testSubject = new OutputGenerator(_writerMock.Object); }
private static void Main(string[] args) { var options = new CommandLineOptions(); try { if (CommandLine.Parser.Default.ParseArguments(args, options)) { LoadReferences(options); string assemblyPath = options.AssemblyPath; HttpConfiguration config = HttpConfigurationImporter.ImportConfiguration(assemblyPath); Collection <ApiDescription> descriptions = config.Services.GetApiExplorer().ApiDescriptions; IOutputGenerator outputGenerator = LoadOutputGenerator(options); outputGenerator.GenerateIndex(descriptions); foreach (var api in descriptions) { HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator(); HelpPageApiModel apiModel = HelpPageConfigurationExtensions.GenerateApiModel(api, sampleGenerator); if (apiModel != null) { outputGenerator.GenerateApiDetails(apiModel); } } } } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } }
public CompareTheWords(IFileReader fileReader, IWordCounter wordCounter, IPrimeNumberCalculator primeNumberCalculator, IOutputGenerator outputGenerator) { _fileReader = fileReader; _wordCounter = wordCounter; _primeNumberCalculator = primeNumberCalculator; _outputGenerator = outputGenerator; }
public BuyCommand(ICmdCoffeeApi cmdCoffeeApi, Func <IAppSettings> appSettingsFactory, IOutputWriter writer, IOutputGenerator outputGenerator) { _cmdCoffeeApi = cmdCoffeeApi; _writer = writer; _outputGenerator = outputGenerator; _appSettings = appSettingsFactory(); }
public GeneratorViewModel(IOutputGenerator generator, ISyntaxParser syntaxParser) { _generator = generator; SyntaxParser = syntaxParser; LinesPerRecord = 1; Delimiter = @"[\s]+"; }
public CommandManager(IPlateu plateu, ICommandMapper commandMapper, ICommandInvoker commandInvoker, IOutputGenerator outputGenerator) { rovers = new List <IRover>(); this.plateu = plateu; this.commandMapper = commandMapper; this.commandInvoker = commandInvoker; this.outputGenerator = outputGenerator; this.commandInvoker.SetPlateu(this.plateu); this.commandInvoker.SetRovers(rovers); }
public Program(string[] args, TextWriter writer, IProcessHelper processHelper, IOutputGenerator outputGenerator, IBrowserAbstraction browserAbstraction) { _args = args; _writer = writer; _processHelper = processHelper; _outputGenerator = outputGenerator; _browserAbstraction = browserAbstraction; }
static string GetDefaultPath(string inputPath, IOutputGenerator generator) { var dotPosition = inputPath.LastIndexOf('.'); if (dotPosition < 0) { return(inputPath + generator.DefaultExtension); } var basePath = inputPath.Substring(0, dotPosition); return(basePath + generator.DefaultExtension); }
public CoffeeCommander(IOutputGenerator outputGenerator, IEnumerable <ICoffeeCommand> coffeeCommandsList, IOutputWriter outputWriter) { _outputGenerator = outputGenerator; _outputWriter = outputWriter; var coffeeCommands = new Dictionary <string, ICoffeeCommand>(); foreach (var coffeeCommand in coffeeCommandsList) { coffeeCommands[coffeeCommand.Name] = coffeeCommand; } CoffeeCommands = coffeeCommands; }
public GitVersionOutputTool(IOptions <GitVersionOptions> options, IOutputGenerator outputGenerator, IWixVersionFileUpdater wixVersionFileUpdater, IGitVersionInfoGenerator gitVersionInfoGenerator, IAssemblyInfoFileUpdater assemblyInfoFileUpdater, IProjectFileUpdater projectFileUpdater) { this.options = options ?? throw new ArgumentNullException(nameof(options)); this.outputGenerator = outputGenerator ?? throw new ArgumentNullException(nameof(outputGenerator)); this.wixVersionFileUpdater = wixVersionFileUpdater ?? throw new ArgumentNullException(nameof(wixVersionFileUpdater)); this.gitVersionInfoGenerator = gitVersionInfoGenerator ?? throw new ArgumentNullException(nameof(gitVersionInfoGenerator)); this.assemblyInfoFileUpdater = assemblyInfoFileUpdater ?? throw new ArgumentNullException(nameof(gitVersionInfoGenerator)); this.projectFileUpdater = projectFileUpdater ?? throw new ArgumentNullException(nameof(projectFileUpdater)); }
/// <summary> /// Initializes a new instance of the <see cref="Game"/> class. /// </summary> /// <param name="inputInterpreter">An <see cref="IInputInterpreter"/> implementation</param> /// <param name="outputGenerator">An <see cref="IOutputGenerator"/> implementation</param> public Game(IInputInterpreter inputInterpreter, IOutputGenerator outputGenerator) { this.inputInterpreter = inputInterpreter; this.outputGenerator = outputGenerator; piece = new Piece(BoardSize, 0, 0, Direction.North); moveMethods = new Dictionary <Move, Action> { { Move.Advance, piece.Advance }, { Move.TurnLeft, piece.TurnLeft }, { Move.TurnRight, piece.TurnRight } }; }
public void Purge(IOutputGenerator outGen, bool main = true, bool draft = true) { foreach (TerrainTile tile in tiles.Tiles()) { if (tile.main?.data != null) { outGen.Purge(tile.main.data, tile.main.terrain); } if (tile.draft?.data != null) { outGen.Purge(tile.draft.data, tile.draft.terrain); } } }
public GitVersionOutputTool(IOptions <GitVersionOptions> options, IOutputGenerator outputGenerator, IWixVersionFileUpdater wixVersionFileUpdater, IGitVersionInfoGenerator gitVersionInfoGenerator, IAssemblyInfoFileUpdater assemblyInfoFileUpdater, IProjectFileUpdater projectFileUpdater) { this.options = options.NotNull(); this.outputGenerator = outputGenerator.NotNull(); this.wixVersionFileUpdater = wixVersionFileUpdater.NotNull(); this.gitVersionInfoGenerator = gitVersionInfoGenerator.NotNull(); this.assemblyInfoFileUpdater = assemblyInfoFileUpdater.NotNull(); this.projectFileUpdater = projectFileUpdater.NotNull(); }
private static void Main(string[] args) { var options = new CommandLineOptions(); try { if (CommandLine.Parser.Default.ParseArguments(args, options)) { LoadReferences(options); string assemblyPath = options.AssemblyPath; HttpConfiguration config = HttpConfigurationImporter.ImportConfiguration(assemblyPath); //Get the ApiExplorer instance, and bind our own XML doc provider to it var explorer = (ApiExplorer)config.Services.GetApiExplorer(); if (!string.IsNullOrEmpty(options.XmlDocPath)) { var docProvider = new XmlDocumentationProvider(options.XmlDocPath); explorer.DocumentationProvider = docProvider; } //And extract our API documentation Collection <ApiDescription> descriptions = explorer.ApiDescriptions; IOutputGenerator outputGenerator = LoadOutputGenerator(options); outputGenerator.GenerateIndex(descriptions); foreach (var api in descriptions) { HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator(); HelpPageApiModel apiModel = HelpPageConfigurationExtensions.GenerateApiModel(api, sampleGenerator); if (apiModel != null) { outputGenerator.GenerateApiDetails(apiModel); } } } } catch (Exception e) { Console.WriteLine("Error: {0}", e.Message); } }
public GitVersionTool(ILog log, INextVersionCalculator nextVersionCalculator, IVariableProvider variableProvider, IGitPreparer gitPreparer, IGitVersionCache gitVersionCache, IGitVersionCacheKeyFactory cacheKeyFactory, IOutputGenerator outputGenerator, IWixVersionFileUpdater wixVersionFileUpdater, IGitVersionInfoGenerator gitVersionInfoGenerator, IAssemblyInfoFileUpdater assemblyInfoFileUpdater, IOptions <GitVersionOptions> options, Lazy <GitVersionContext> versionContext) { this.log = log ?? throw new ArgumentNullException(nameof(log)); this.nextVersionCalculator = nextVersionCalculator ?? throw new ArgumentNullException(nameof(nextVersionCalculator)); this.variableProvider = variableProvider ?? throw new ArgumentNullException(nameof(variableProvider)); this.gitPreparer = gitPreparer ?? throw new ArgumentNullException(nameof(gitPreparer)); this.cacheKeyFactory = cacheKeyFactory ?? throw new ArgumentNullException(nameof(cacheKeyFactory)); this.gitVersionCache = gitVersionCache ?? throw new ArgumentNullException(nameof(gitVersionCache)); this.outputGenerator = outputGenerator ?? throw new ArgumentNullException(nameof(outputGenerator)); this.wixVersionFileUpdater = wixVersionFileUpdater ?? throw new ArgumentNullException(nameof(wixVersionFileUpdater)); this.gitVersionInfoGenerator = gitVersionInfoGenerator ?? throw new ArgumentNullException(nameof(gitVersionInfoGenerator)); this.assemblyInfoFileUpdater = assemblyInfoFileUpdater ?? throw new ArgumentNullException(nameof(gitVersionInfoGenerator)); this.options = options ?? throw new ArgumentNullException(nameof(options)); this.versionContext = versionContext ?? throw new ArgumentNullException(nameof(versionContext)); }
public bool TryGetGeneratorByFormat(string format, out IOutputGenerator generator) { generator = AllGenerators.FirstOrDefault(x => x.Format == format); return(generator != null); }
public PageWriter(IOutputGenerator generator, IOutputWriter writer, IPatternTemplateResolver patternTemplateResolver) { this.generator = generator; this.patternTemplateResolver = patternTemplateResolver; this.writer = writer; }
public ConsoleOutputHandler(IOutputGenerator output, IFile file, IConsole console) { _output = output; _file = file; _console = console; }
/// <summary> /// Initializes a new instance of the <see cref="T:PDFParser.PDFReader"/> class. /// </summary> /// <param name="inputAccessor">Input accessor.</param> /// <param name="outputGenerator">Output generator.</param> public PDFReader(IInputAccessor inputAccessor, IOutputGenerator outputGenerator) { InputAccessor = inputAccessor; OutputGenerator = outputGenerator; }
public override bool Execute() { List <DBObjectType> dataToExtract = GetDataToExtractEnum(); List <DBObjectType> dataToGenerateOutput = GetDataToGenerateOutputEnum(); ExtractionType exType; if (this.extractiontype.ToLower() == "database") { exType = ExtractionType.Database; } else if (this.extractiontype == "script") { exType = ExtractionType.Script; } else { throw new Exception(String.Format("Invalid extraction type: {0}", this.extractiontype)); } Database db = null; List <BaseStatement> statementCol = null; if (exType == ExtractionType.Database) { if (String.IsNullOrEmpty(_DBExtractorClass)) { throw new Exception("For database extraction type, dbextractorclass is required"); } Type dbExtractorClass = Type.GetType(_DBExtractorClass); if (dbExtractorClass == null) { throw new Exception(String.Format("Couldn't create instance for type {0}", _DBExtractorClass)); } IDatabaseExtractor dbExtractor = (IDatabaseExtractor)Activator.CreateInstance(dbExtractorClass); DatabaseExtractor extractor = new DatabaseExtractor(); extractor.Extractor = dbExtractor; extractor.InputConnectionString = _InputConnectionString; db = extractor.Extract(dataToExtract); } else { if (String.IsNullOrEmpty(ScriptExtractorClass)) { throw new Exception("For script extraction type, scriptextractorclass is required"); } Type scriptExtractorClass = Type.GetType(ScriptExtractorClass); if (scriptExtractorClass == null) { throw new Exception(String.Format("Couldn't create instance for type {0}", scriptExtractorClass)); } IScriptExtractor scriptExtractor = (IScriptExtractor)Activator.CreateInstance(scriptExtractorClass); if (_InputFiles == null) { throw new Exception("InputFiles must be specified."); } foreach (ITaskItem file in _InputFiles) { scriptExtractor.InputFiles.Add(file.ItemSpec); } statementCol = scriptExtractor.Extract(dataToExtract); } Type outputGenClass = Type.GetType(_OutputGeneratorClass); if (outputGenClass == null) { throw new Exception(String.Format("Couldn't create instance for type {0}", _OutputGeneratorClass)); } IOutputGenerator gen = (IOutputGenerator)Activator.CreateInstance(outputGenClass); if (gen.ExpectedInputType == ExpectedInputType.StatementCollection) { if (statementCol == null) { DatabaseToStatementCollectionConverter conv = new DatabaseToStatementCollectionConverter(); statementCol = conv.Convert(db); } Type scriptOutputGenClass = Type.GetType(_ScriptOutputGeneratorClass); if (((IStatementCollectionOutputGenerator)gen).RequiresScriptOutputHandler) { if (scriptOutputGenClass == null) { throw new Exception(String.Format("Couldn't create instance for type {0}", _ScriptOutputGeneratorClass)); } IScriptOutputHandler scriptOutputGen = (IScriptOutputHandler)Activator.CreateInstance(scriptOutputGenClass); ((IStatementCollectionOutputGenerator)gen).ScriptOutputGen = scriptOutputGen; } if (String.IsNullOrEmpty(ScriptFileOutputGenerator)) { throw new Exception(String.Format("For output file type you must specify ScriptFileOutputGenerator")); } Type scriptFileOutputGeneratorType = Type.GetType(ScriptFileOutputGenerator); if (scriptFileOutputGeneratorType == null) { throw new Exception(String.Format("Couldn't create instance for type {0}", ScriptFileOutputGenerator)); } ((IStatementCollectionOutputGenerator)gen).ScriptFileOutputGenerator = (IScriptFileOutputGenerator)Activator.CreateInstance(scriptFileOutputGeneratorType); gen.OutputDir = OutputDir; ((IStatementCollectionOutputGenerator)gen).GenerateOutput(statementCol, dataToGenerateOutput); } else { StatementCollectionToDatabaseConverter conv = new StatementCollectionToDatabaseConverter(); db = conv.Convert(statementCol); gen.OutputDir = OutputDir; ((IDBSchemaOutputGenerator)gen).GenerateOutput(db, dataToGenerateOutput); } return(true); }
static void GenerateAndSave(IOutputGenerator generator, string outputPath, AnalysisResult analysisResult) { var outputCode = generator.generateCode(analysisResult); File.WriteAllText(outputPath, outputCode); }
public CompileLog GenerateDefinition(StringBuilder codeBuilder, IOutputGenerator outputGenerator) { return(new CompileLog()); //Nothing to Define for Build-Ins (should be simply typedefed in generator) }
public void GenerateDocumentation(IOutputGenerator generator, IGame game) { Console.WriteLine(Resources.GeneratingDocumentation, generator.Name, generator.Version); generator.Generate(game); Console.WriteLine(Resources.FinishedGeneratingDocumentation); }
public bool TryGetGeneratorByFileExtension(string extension, out IOutputGenerator generator) { generator = AllGenerators.FirstOrDefault(x => x.FileExtension == extension); return(generator != null); }
public ProductsCommand(IOutputGenerator outputGenerator, ICmdCoffeeApi cmdCoffeeApi, IOutputWriter outputWriter) { _outputGenerator = outputGenerator; _cmdCoffeeApi = cmdCoffeeApi; _outputWriter = outputWriter; }
public CompileLog GenerateDeclaration(StringBuilder codeBuilder, IOutputGenerator outputGenerator) { return(new CompileLog()); //Should be Build in in every Language }