public FileModel GetOrCreateFile(string fullPath) { if (!fullPath.StartsWith(Project.SourceFolderPath)) { throw new ArgumentException("Full path should be subdirectory of a source one.", "fullPath"); } string relativePath = fullPath.Substring(Project.SourceFolderPath.Length); FileModel file = Files.SingleOrDefault(x => x.Path == relativePath); if (file == null) { file = new FileModel(Project) { Path = fullPath.Substring(Project.SourceFolderPath.Length), FullPath = fullPath }; Files.Add(file); } return file; }
private void CompileFile(FileModel file, Project project) { file.Dependencies.Clear(); ManagedCallbackManager.SetFileAccessCallBack(file.AddDependency); try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string output = _compiler.CompileFile(file.FullPath); // Save file into physical one if it is not mixin file if (!Path.GetFileName(file.FullPath).StartsWith("_")) { // TODO: Save file here } stopwatch.Stop(); Log(project, String.Format("Successfully compiled file at {0}, compilation took {1} ms", file.Path, stopwatch.ElapsedMilliseconds)); } catch (SassCompileException ex) { Log(project, String.Format("Error while preprocessing file at {0}:{1}{2}", file.Path, Environment.NewLine, ex.Message)); } ManagedCallbackManager.UnsetFileAccessCallBack(); }