private void LoadDefaults() { Language = Configuration.CodeGeneration.GetLanguage(); RootPath = Configuration.CodeGeneration.GetOutputPath(); RootFile = Configuration.CodeGeneration.GetOutputFile(); RootPath = RootPath.Replace("\\.\\", "\\"); CodeGenerationFileType[] types = { CodeGenerationFileType.AttributeConstants, CodeGenerationFileType.Entities, CodeGenerationFileType.OptionSets, CodeGenerationFileType.Requests, CodeGenerationFileType.Responses, CodeGenerationFileType.ServiceContext }; foreach (var type in types) { var options = Configuration.CodeGeneration.GetOutputOptions(type); string file = options.GetComputedFile(RootPath); string path = Path.GetDirectoryName(file); OutputFiles.Add(type, file); OutputPaths.Add(type, path); } }
public void AddOutputFile(string path, DateTime timestamp, bool shouldExist) { OutputFiles.Add(path); if (shouldExist) { myFileSystem.AddFile(path, timestamp); } }
public WorkerGenerationJob(string baseOutputDir, IFileSystem fileSystem, DetailsStore detailsStore) : base(baseOutputDir, fileSystem, detailsStore) { workerTypesToGenerate = ExtractWorkerTypes(CodeGeneratorOptions.Instance.WorkerJsonDirectory); OutputFiles.Add(Path.Combine(relativeEditorPath, workerFileName)); OutputFiles.Add(Path.Combine(relativeEditorPath, workerListFileName)); OutputFiles.Add(Path.Combine(relativeOutputPath, buildSystemFileName)); }
private void Render(PascalTreeWriter treeWriter, string path) { var writer = new CsRender(); treeWriter.InsertUsings(); treeWriter.Tree.Resolve(writer); writer.Write(path); OutputFiles.Add(path); }
public void MoveOutputFiles() { //Ensure the the first file is the first in TempOutputFiles TempOutputFiles = TempOutputFiles.OrderBy(x => x).ToList(); _outfilebody = DetermineOutfileBody(); var isFirstFile = true; foreach (var tempOutputFile in TempOutputFiles) { var extension = PathSafe.GetExtension(tempOutputFile); var num = DetermineNumWithDigits(tempOutputFile); _currentOutputFile = _outfilebody + num + extension; //first file in interactive workflow if (isFirstFile && !Profile.AutoSave.Enabled && OnRetypeOutputFilename != null) { if (!CopyFileWithInteractiveOutputFilenameTemplateQuery(tempOutputFile, num, extension)) { return; //cancelled by user } } else { lock (LockObject) { var uniqueFilename = new UniqueFilename(_currentOutputFile, DirectoryWrap, FileWrap); if (Profile.AutoSave.Enabled && Profile.AutoSave.EnsureUniqueFilenames) { _currentOutputFile = EnsureUniqueFilename(uniqueFilename); } if (!CopyFile(tempOutputFile, _currentOutputFile)) { _currentOutputFile = EnsureUniqueFilename(uniqueFilename); if (!CopyFile(tempOutputFile, _currentOutputFile)) { //Throw exception after second attempt to copy failes. throw new DeviceException( "Error while copying to target file in second attempt. Process gets canceled.", 2); } } } } DeleteFile(tempOutputFile); OutputFiles.Add(_currentOutputFile); isFirstFile = false; } OutputFiles = OutputFiles.OrderBy(x => x).ToList(); }
private void MoveOutputFile(string file) { var fileMover = new SingleFileMover(); if (Profile.AutoSave.Enabled && Profile.AutoSave.EnsureUniqueFilenames) { fileMover.UniqueFileNameEnabled = true; } var movedFile = fileMover.MoveSingleOutputFile(file, OutputFilenameTemplate); OutputFiles.Add(movedFile); }
private static void loadOutputFiles(BinaryReader reader) { // Clear current list of output files OutputFiles.Clear(); // Get number of output files int count = reader.ReadInt32(); // For each output file for (int i = 0; i < count; i++) { // Get output file string file = reader.ReadString(); // Add output file to list OutputFiles.Add(file); } }
public void ModifyProjectFile(string path) { if (!File.Exists(path)) { Errors.Warn("Project file " + path + " not found!"); return; } XmlDocument proj = new XmlDocument(); proj.Load(path); var projectDir = Path.GetDirectoryName(path); bool modified = false; var csns = "http://schemas.microsoft.com/developer/msbuild/2003"; XmlNamespaceManager nsm = new XmlNamespaceManager(proj.NameTable); nsm.AddNamespace("x", csns); var projectRoot = proj.SelectSingleNode("x:Project", nsm); var generatedGroup = proj.SelectSingleNode("x:Project/x:ItemGroup[@Label='Gluon Generated']", nsm) as XmlElement; if (generatedGroup == null) { generatedGroup = (XmlElement)projectRoot.AppendChild(proj.CreateElement("ItemGroup", csns)); generatedGroup.SetAttribute("Label", "Gluon Generated"); modified = true; } Action <string> ensureSource = source => { var relsource = U.GetRelativePath(source, projectDir); var el = (XmlElement)proj.SelectSingleNode("x:Project/x:ItemGroup/x:Compile[translate(@Include, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = '" + relsource.ToLower() + "']", nsm); if (el == null) { el = proj.CreateElement("Compile", csns); el.SetAttribute("Include", relsource); generatedGroup.AppendChild(el); if (relsource.StartsWith("..")) { var linkel = proj.CreateElement("Link", csns); var linkPath = U.GetRelativePath(source, Settings.OutputFolder); linkel.InnerText = linkPath; el.AppendChild(linkel); } modified = true; } }; foreach (var file in OutputFiles) { if (file.EndsWith(".cs", StringComparison.InvariantCultureIgnoreCase)) { ensureSource(file); } } OutputFiles.Add(path); if (modified) { proj.Save(path); } }
public void ProcessCumulativeData(List <Metrics> metrics) { foreach (Metrics metric in metrics) { // 1) Create a new List<CalculatedValue> List <CalculatedValue> processedValues = new List <CalculatedValue>(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) List <CalculatedValue> allValues = new List <CalculatedValue>(); string namedMetric = "jh-cumulative-"; switch (metric) { case Metrics.Deaths: namedMetric += "deaths"; foreach (JhCovidDay sd in CoreStateData.CovidData) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(sd.Deaths), sd.Date)); } break; case Metrics.Cases: namedMetric += "positives"; foreach (JhCovidDay sd in CoreStateData.CovidData) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(sd.Positives), sd.Date)); } break; case Metrics.Tests: namedMetric += "tests"; foreach (JhCovidDay sd in CoreStateData.CovidData) { double tests = Convert.ToDouble(sd.Tests); allValues.Add(new CalculatedValue(namedMetric, tests, sd.Date)); } break; case Metrics.PercentPositive: namedMetric += "percentPositive"; foreach (JhCovidDay sd in CoreStateData.CovidData) { double percentPositive = Convert.ToDouble(sd.Positives) / Convert.ToDouble(sd.Tests); allValues.Add(new CalculatedValue(namedMetric, percentPositive, sd.Date)); } break; default: break; } // Add all the cumulative items OutputFiles.Add(namedMetric, allValues); // 3) do the per capita calculation if (metric != Metrics.PercentPositive) { foreach (CalculatedValue cv in allValues) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreStateData.State.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; OutputFiles.Add(namedMetric, processedValues); } } }
public void ProcessDailyData(List <Metrics> metrics, bool isRollingAverage = true, int rollingAverage = 7) { //List<StateDay> sortedDays = CoreStateData.CovidData.OrderByDescending(d => d.DateInt).ToList(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) foreach (Metrics metric in metrics) { List <CalculatedValue> processedValues = new List <CalculatedValue>(); List <CalculatedValue> preProcess = new List <CalculatedValue>(); string namedMetric = "jh-daily-"; switch (metric) { case Metrics.Deaths: namedMetric += "deaths"; foreach (JhCovidDay sd in CoreStateData.CovidData) { preProcess.Add(new CalculatedValue(namedMetric, sd.Deaths, sd.Date)); } break; case Metrics.Cases: namedMetric += "positives"; foreach (JhCovidDay sd in CoreStateData.CovidData) { preProcess.Add(new CalculatedValue(namedMetric, sd.Positives, sd.Date)); } break; case Metrics.Tests: namedMetric += "tests"; foreach (JhCovidDay sd in CoreStateData.CovidData) { double tests = sd.Tests; preProcess.Add(new CalculatedValue(namedMetric, sd.Tests, sd.Date)); } break; case Metrics.PercentPositive: namedMetric += "percentPositive"; foreach (JhCovidDay sd in CoreStateData.CovidData) { double percentPositive = sd.Positives / sd.Tests; preProcess.Add(new CalculatedValue(namedMetric, percentPositive, sd.Date)); } break; default: break; } // 3) doing a rolling average? roll that average List <CalculatedValue> averageValues = new List <CalculatedValue>(); foreach (CalculatedValue cv in preProcess) { var comparativeDate = cv.Date - new TimeSpan(rollingAverage, 0, 0, 0); var comparativeValue = preProcess.FirstOrDefault(val => val.Date.Date == comparativeDate); if (comparativeValue == null) { averageValues.Add(new CalculatedValue(cv.MetricName, 0, cv.Date)); } else if (cv.MetricName.Contains("percentPositive")) { var percentPos = GetPercentPositiveRollingAvg(cv.Date, rollingAverage); averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", percentPos, cv.Date)); } else { var avgValue = (cv.Value - comparativeValue.Value) / rollingAverage; averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", avgValue, cv.Date)); } } if (isRollingAverage) { namedMetric += "-" + rollingAverage.ToString() + "dayavg"; preProcess = averageValues; } OutputFiles.Add(namedMetric, preProcess); // 4) do a perCapita calculation if (metric != Metrics.PercentPositive) { foreach (CalculatedValue cv in preProcess) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreStateData.State.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; OutputFiles.Add(namedMetric, processedValues); } } }
public void ProcessDailyData(List <Metrics> metrics, bool isRollingAverage = false, int rollingAverage = 7, bool isPerCapita = true) { //List<StateDay> sortedDays = CoreStateData.CovidData.OrderByDescending(d => d.DateInt).ToList(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) foreach (Metrics metric in metrics) { List <CalculatedValue> processedValues = new List <CalculatedValue>(); List <CalculatedValue> preProcess = new List <CalculatedValue>(); string namedMetric = "dailychange-"; switch (metric) { case Metrics.DosesAdministered: namedMetric += "dosesAdmin"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { if (isPerCapita) { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.AdministeredPer100K), vs.Date)); } else { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.DosesAdministered), vs.Date)); } } break; case Metrics.DosesDistributed: namedMetric += "dosesDist"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { if (isPerCapita) { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.DistributedPer100K), vs.Date)); } else { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.DosesDistributed), vs.Date)); } } break; case Metrics.SeriesCompleteAdultPct: namedMetric += "adultPctVaccinated"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { preProcess.Add(new CalculatedValue(namedMetric, vs.PercentAdultVaccinated, vs.Date)); } break; case Metrics.SeriesCompleteSeniorPct: namedMetric += "seniorsPctVaccinated"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { preProcess.Add(new CalculatedValue(namedMetric, vs.PercentSeniorsVaccinated, vs.Date)); } break; default: break; } List <CalculatedValue> averageValues = new List <CalculatedValue>(); foreach (CalculatedValue cv in preProcess) { var comparativeDate = cv.Date - new TimeSpan(rollingAverage, 0, 0, 0); var comparativeValue = preProcess.FirstOrDefault(val => val.Date.Date == comparativeDate); if (comparativeValue == null) { averageValues.Add(new CalculatedValue(cv.MetricName, 0, cv.Date)); } else { var avgValue = (cv.Value - comparativeValue.Value) / rollingAverage; averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", avgValue, cv.Date)); } } if (isRollingAverage) { namedMetric += "-" + rollingAverage.ToString() + "dayavg"; preProcess = averageValues; } if (isPerCapita) { foreach (CalculatedValue cv in preProcess) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreVaccineStateData.StateBase.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; } else { processedValues = preProcess; } OutputFiles.Add(namedMetric, processedValues); } }
public void ProcessCumulativeData(List <Metrics> metrics, bool isPerCapita = true) { foreach (Metrics metric in metrics) { // 1) Create a new List<CalculatedValue> List <CalculatedValue> processedValues = new List <CalculatedValue>(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) List <CalculatedValue> allValues = new List <CalculatedValue>(); string namedMetric = "cumulative-"; switch (metric) { case Metrics.DosesAdministered: namedMetric += "dosesAdmin"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { if (isPerCapita) { allValues.Add(new CalculatedValue(namedMetric + "-per100K", Convert.ToDouble(vs.AdministeredPer100K), vs.Date)); } else { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.DosesAdministered), vs.Date)); } } break; case Metrics.DosesDistributed: namedMetric += "dosesDist"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { if (isPerCapita) { allValues.Add(new CalculatedValue(namedMetric + "-per100K", Convert.ToDouble(vs.DistributedPer100K), vs.Date)); } else { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(vs.DosesDistributed), vs.Date)); } } break; case Metrics.SeriesCompleteAdultPct: namedMetric += "adultPctVaccinated"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { allValues.Add(new CalculatedValue(namedMetric, vs.PercentAdultVaccinated, vs.Date)); } break; case Metrics.SeriesCompleteSeniorPct: namedMetric += "seniorsPctVaccinated"; foreach (VaccineDay vs in CoreVaccineStateData.VaccineData) { allValues.Add(new CalculatedValue(namedMetric, vs.PercentSeniorsVaccinated, vs.Date)); } break; default: break; } if (isPerCapita) { namedMetric += "-per100K"; } OutputFiles.Add(namedMetric, allValues); } }
public TestCodegenJob(string baseOutputDir, IFileSystem fileSystem, DetailsStore detailsStore) : base( baseOutputDir, fileSystem, detailsStore) { OutputFiles.Add(relativeOutputPath); OutputFiles.Add(relativeTemplateOutputPath); }
public void ProcessDailyData(List <Metrics> metrics, bool isRollingAverage = false, int rollingAverage = 7, bool isPerCapita = true) { //List<StateDay> sortedDays = CoreStateData.CovidData.OrderByDescending(d => d.DateInt).ToList(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) foreach (Metrics metric in metrics) { List <CalculatedValue> processedValues = new List <CalculatedValue>(); List <CalculatedValue> preProcess = new List <CalculatedValue>(); string namedMetric = "world-dailychange-"; switch (metric) { case Metrics.Deaths: namedMetric += "deaths"; foreach (OwidDay od in CoreCountryData.Data) { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(od.TotalDeaths), od.Date)); } break; case Metrics.Cases: namedMetric += "positives"; foreach (OwidDay od in CoreCountryData.Data) { preProcess.Add(new CalculatedValue(namedMetric, Convert.ToDouble(od.TotalCases), od.Date)); if (CoreCountryData.CountryName == "Germany") { Debug.WriteLine("Germany - " + od.DateString + " - positives - " + od.TotalCases + ", " + od.NewCases); } } break; case Metrics.Tests: namedMetric += "tests"; foreach (OwidDay od in CoreCountryData.Data) { double tests = Convert.ToDouble(od.TotalCases) + Convert.ToDouble(od.TotalTests); preProcess.Add(new CalculatedValue(namedMetric, tests, od.Date)); } break; case Metrics.PercentPositive: namedMetric += "percentPositive"; foreach (OwidDay od in CoreCountryData.Data) { double percentPositive = Convert.ToDouble(od.TotalCases) / Convert.ToDouble(od.TotalTests); preProcess.Add(new CalculatedValue(namedMetric, percentPositive, od.Date)); } break; case Metrics.CaseJerk: namedMetric += "caseJerk"; break; default: break; } // 3) doing a rolling average? roll that average List <CalculatedValue> averageValues = new List <CalculatedValue>(); foreach (CalculatedValue cv in preProcess) { var comparativeDate = cv.Date - new TimeSpan(rollingAverage, 0, 0, 0); var comparativeValue = preProcess.FirstOrDefault(val => val.Date.Date == comparativeDate); if (comparativeValue == null) { averageValues.Add(new CalculatedValue(cv.MetricName, 0, cv.Date)); } else if (cv.MetricName.Contains("percentPositive")) { var percentPos = GetPercentPositiveRollingAvg(cv.Date, rollingAverage); averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", percentPos, cv.Date)); } else if (cv.MetricName.Contains("currentHospital")) { var hospitalVals = preProcess.FindAll(val => val.Date.Date < cv.Date.Date && val.Date.Date >= comparativeValue.Date.Date); double allHospitalVals = 0; foreach (CalculatedValue otherCv in hospitalVals) { allHospitalVals += otherCv.Value; } allHospitalVals = allHospitalVals / rollingAverage; averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", allHospitalVals, cv.Date)); } else { var avgValue = (cv.Value - comparativeValue.Value) / rollingAverage; averageValues.Add(new CalculatedValue(cv.MetricName + "-" + rollingAverage.ToString() + "dayavg", avgValue, cv.Date)); } } if (isRollingAverage) { namedMetric += "-" + rollingAverage.ToString() + "dayavg"; preProcess = averageValues; } // 4) do a perCapita calculation if (isPerCapita && metric != Metrics.PercentPositive) { foreach (CalculatedValue cv in preProcess) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreCountryData.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; } else { processedValues = preProcess; } OutputFiles.Add(namedMetric, processedValues); } }
public void ProcessCumulativeData(List <Metrics> metrics, bool isPerCapita = true) { foreach (Metrics metric in metrics) { // 1) Create a new List<CalculatedValue> List <CalculatedValue> processedValues = new List <CalculatedValue>(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) List <CalculatedValue> allValues = new List <CalculatedValue>(); string namedMetric = "world-cumulative-"; switch (metric) { case Metrics.Deaths: namedMetric += "deaths"; foreach (OwidDay od in CoreCountryData.Data) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(od.TotalDeaths), od.Date)); } break; case Metrics.Cases: namedMetric += "positives"; foreach (OwidDay od in CoreCountryData.Data) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(od.TotalCases), od.Date)); } break; case Metrics.Tests: namedMetric += "tests"; foreach (OwidDay od in CoreCountryData.Data) { double tests = Convert.ToDouble(od.TotalTests); allValues.Add(new CalculatedValue(namedMetric, tests, od.Date)); } break; case Metrics.PercentPositive: namedMetric += "percentPositive"; foreach (OwidDay od in CoreCountryData.Data) { double percentPositive = Convert.ToDouble(od.TotalCases) / Convert.ToDouble(od.TotalTests); allValues.Add(new CalculatedValue(namedMetric, percentPositive, od.Date)); } break; default: break; } // 3) do the per capita calculation if (isPerCapita && metric != Metrics.PercentPositive) { foreach (CalculatedValue cv in allValues) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreCountryData.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; } else { processedValues = allValues; } OutputFiles.Add(namedMetric, processedValues); } }
public void ProcessCumulativeData(List <Metrics> metrics, bool isPerCapita = true) { foreach (Metrics metric in metrics) { // 1) Create a new List<CalculatedValue> List <CalculatedValue> processedValues = new List <CalculatedValue>(); // 2) Look at the metric, pick out the appropriate data for that metric (and give it a name) List <CalculatedValue> allValues = new List <CalculatedValue>(); string namedMetric = "cumulative-"; switch (metric) { case Metrics.Deaths: namedMetric += "deaths"; foreach (StateDay sd in CoreStateData.CovidData) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(sd.Death), sd.Date)); } break; case Metrics.Cases: namedMetric += "positives"; foreach (StateDay sd in CoreStateData.CovidData) { allValues.Add(new CalculatedValue(namedMetric, Convert.ToDouble(sd.Positive), sd.Date)); } break; case Metrics.Tests: namedMetric += "tests"; foreach (StateDay sd in CoreStateData.CovidData) { double tests = Convert.ToDouble(sd.Positive) + Convert.ToDouble(sd.Negative); allValues.Add(new CalculatedValue(namedMetric, tests, sd.Date)); } break; case Metrics.PercentPositive: namedMetric += "percentPositive"; foreach (StateDay sd in CoreStateData.CovidData) { double percentPositive = Convert.ToDouble(sd.Positive) / Convert.ToDouble(sd.Negative + sd.Positive); allValues.Add(new CalculatedValue(namedMetric, percentPositive, sd.Date)); } break; case Metrics.HospitalCurrent: namedMetric += "currentHosp"; foreach (StateDay sd in CoreStateData.CovidData) { double currentHosp = sd.HospitalizedCurrently != null?Convert.ToDouble(sd.HospitalizedCurrently) : 0; allValues.Add(new CalculatedValue(namedMetric, currentHosp, sd.Date)); } break; case Metrics.CaseJerk: namedMetric += "caseJerk"; break; default: break; } // 3) do the per capita calculation if (isPerCapita && metric != Metrics.PercentPositive) { foreach (CalculatedValue cv in allValues) { processedValues.Add(new CalculatedValue(namedMetric, ((cv.Value / CoreStateData.StateBase.Population) * 100000), cv.Date)); } namedMetric += "-per100K"; } else { processedValues = allValues; } OutputFiles.Add(namedMetric, processedValues); } }
/// <summary> /// Add a MetalsharpFile to the input files /// </summary> /// /// <example> /// ```c# /// new MetalsharpProject() /// .AddInput(new MetalsharpFile("# File Text", "path\\to\\file.md"); /// ``` /// </example> /// /// <param name="file"> /// The file to add. /// </param> /// /// <returns> /// The current `MetalsharpProject`, allowing it to be fluent. /// </returns> public MetalsharpProject AddOutput(MetalsharpFile file) { OutputFiles.Add(file); return(this); }