string GetOutputFileName(EngineResult result, string filename, EngineContainer engine) { var baseFileName = filename; if (!string.IsNullOrEmpty(result.FileName)) { baseFileName = result.FileName; } var inputExtension = ExtensionResolver.GetExtensionFromCategory(engine.Category); if (baseFileName.EndsWith(inputExtension)) { baseFileName = filename.Substring(0, filename.Length - inputExtension.Length); } else { baseFileName = FileHandler.GetBaseFileName(baseFileName); } return(string.Format("{0}.{1}", baseFileName, result.Extension)); }
void SaveDependencies(ProjectItem projectItem, string filename, string contents, EngineContainer engine) { RemoveDependenciesForFile(projectItem); var dependencies = engine.GetDependencies(contents, filename); if (dependencies == null) { return; } AddDependenciesForFile(projectItem, filename, dependencies); }
IEnumerable <FileAssociation> ProcessEngine(ProjectItem projectItem, string filename, EngineContainer engine) { List <EngineResult> engineResults = null; try { var contents = FileHandler.GetContents(filename); engineResults = engine.Process(contents, filename); } catch (Exception e) { TaskList.Add(e.Message, filename, ErrorCategory.Error); Console.WriteLine("{0}", e.Message); } if (engineResults == null) { yield break; } foreach (var engineResult in engineResults) { if (engineResult.Exceptions.Any()) { var error = false; foreach (var exception in engineResult.Exceptions) { if (string.IsNullOrEmpty(exception.FileName)) { exception.FileName = filename; } error = error || exception.Category == ErrorCategory.Error; TaskList.Add(exception); } if (error) { continue; } } if (engineResult.Contents == null) { continue; } var outputFilename = engineResult.FileName; if (!string.IsNullOrEmpty(engineResult.Extension)) { outputFilename = GetOutputFileName(engineResult, filename, engine); } outputFilename = FileHandler.GetAbsoluteFileName(outputFilename, filename); FileHandler.SaveFile(outputFilename, engineResult.Contents); yield return(new FileAssociation(outputFilename, projectItem)); Logger.Log(string.Format("{0} > {1}", engine.Name, outputFilename)); } }