internal static BuildProviderInfo GetBuildProviderInfo(System.Web.Configuration.CompilationSection config, string extension) { Debug.Assert(extension != null); var entry = config.BuildProviders[extension]; if (entry != null) { return(entry.BuildProviderInfo); } BuildProviderInfo info = null; s_dynamicallyRegisteredProviders.TryGetValue(extension, out info); return(info); }
private string LoadJsxFile(string file) { var result = ""; var isDebugEnable = true; System.Web.Configuration.CompilationSection ds = (System.Web.Configuration.CompilationSection)ConfigurationManager.GetSection("system.web/compilation"); isDebugEnable = ds.Debug; using (System.IO.StreamReader reader = new System.IO.StreamReader(file)) { var path = System.IO.Path.GetDirectoryName(file); var msg = reader.ReadLine(); while (true) { var varName = ""; var subFile = ""; var import = false; var export = false; var line = msg.Trim(); if (line.Length >= 6 && line.Substring(0, 6).ToLower() == "import") { import = true; //import utils from '../utils'; var fromPosition = line.ToLower().IndexOf(" from "); if (fromPosition > 0) { varName = line.Substring(7, fromPosition - 7); subFile = line.Substring(fromPosition + 7, line.Length - fromPosition - 7); } else { subFile = line.Substring(7, line.Length - 7); } } else if (line.Length >= 15 && line.Substring(0, 15).ToLower() == "export default ") { //export default export = true; result += line.Substring(15, line.Length - 15) + "\r\n"; } else if (line.Length >= 8 && line.Substring(0, 8).ToLower() == "console.") { if (isDebugEnable) { result += msg + "\r\n"; } } else { result += msg + "\r\n"; } if (subFile != "") { subFile = subFile.Replace("'", "").Replace(";", ""); subFile = System.IO.Path.Combine(path, subFile); subFile = System.IO.Path.GetFullPath(subFile); if (subFile.Substring(subFile.Length - 1, 1) == "\\") { subFile += "index"; } var exists = System.IO.File.Exists(subFile + ".js"); if (exists) { subFile += ".js"; } else { exists = System.IO.File.Exists(subFile + ".jsx"); if (exists) { subFile += ".jsx"; } } if (exists) { if (varName == "") { var filecontent = LoadJsxFile(subFile); if (filecontent.Length > 1 && filecontent.Trim().Substring(0, 1) == "{") { result += "extend(window," + filecontent.Trim() + ");\r\n"; } else { result += filecontent; } } else { result += "var " + varName + " = " + LoadJsxFile(subFile); } } //result += "{ " + // "name:'" + varName + "'," + // "subFile:'" + subFile + "'," + // "exists:'" + exists.ToString() + "'," + // "export:'" + export.ToString() + "'," + // "}"; } if (reader.EndOfStream) { break; } msg = reader.ReadLine(); } } return(result); }