public bool NeedsBuilding() { var file = context.Request.AppRelativeCurrentExecutionFilePath; if (file.EndsWith("axd")) { return(Doc(XamlScene.CreateXsd(Context.Request.QueryString))); } else if (file.EndsWith(".xic.xaml")) { return(DocFile(file)); } else if (file.EndsWith(".xaml")) { return(Doc(XamlScene.CreateDirect(file, Context.Request.QueryString))); } else { return(DocFile(System.IO.Path.GetFileNameWithoutExtension(filename))); } }
/* * void RawCompile(IEnumerable<string> SourceFiles, string ProjectPath, string LibraryPath) { * * foreach (var src in * Compile(SourceFiles, RebuildAll, ProjectPath, LibraryPath, true, true, false); * } */ void Compile(string filename) { SkinPath = ProjectPath; bool xaml = false; string dxaml = null; if (filename.Trim()[0] == '#') { filename = (string)Context.Session[filename]; } if (filename.Trim()[0] == '<') { dxaml = filename; var res = Parameters.TryGetValue("File", out filename) || Parameters.TryGetValue("Filename", out filename) || Parameters.TryGetValue("Image", out filename); if (!res) { filename = Path.Combine(SkinPath, "direct.xic.xaml"); } xaml = true; } filename = MapPath(filename); var sourceLock = FileLock(filename); try { var root = new Group(); root.Filename = filename; root.Compiler = this; if (!CheckBuilding) { root.Errors.Status("XamlImageConverter 3.2 by Chris Cavanagh & David Egli"); root.Errors.Status("{0:G}, using {1} CPU cores.", DateTime.Now, Cpus); root.Errors.Status(Path.GetFileName(filename) + ":"); } if (string.IsNullOrEmpty(ProjectPath)) { ProjectPath = Path.GetDirectoryName(filename); } SkinPath = Path.GetDirectoryName(filename); List <string> directExtensions = new List <string> { ".xaml", ".psd", ".svg", ".svgz", ".html" }; XElement config = null; DateTime Version = DateTime.MaxValue; try { if (!RebuildAll) { FileInfo info = new FileInfo(filename); if (info.Exists) { Version = info.LastWriteTimeUtc; } } Errors.Path = filename; var ext = Path.GetExtension(filename).ToLower(); if (xaml) { Version = DateTime.MinValue; using (var r = new StringReader(dxaml)) { var xdoc = XElement.Load(r, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo | LoadOptions.SetBaseUri); if (xdoc.Name == xic + "XamlImageConverter" || xdoc.Name == sb + "SkinBuilder") { config = xdoc; } else { config = XamlScene.CreateDirect(this, null, xdoc, Parameters); } } } else if (directExtensions.Any(x => ext == x)) { config = XamlScene.CreateDirect(this, filename, Parameters); } else if (filename == "xic.axd" || filename.EndsWith("\\xic.axd")) { config = XamlScene.CreateAxd(this, filename, Parameters); } else { using (FileLock(filename)) { config = XElement.Load(filename, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo | LoadOptions.PreserveWhitespace); } } } catch (FileNotFoundException) { root.Errors.Error("Unable to read the configuration file", "1"); return; } catch (Exception ex) { root.Errors.Error(ex.Message, "21", null, ex); return; } if (config != null) { Compile(root, Version, config); } //if (!CheckBuilding) root.ExitProcess(null); } catch { } finally { sourceLock.Dispose(); } }