public static void WriteClientAssetsDebugMode(HtmlDocument document, bool devMode, string bundleName = "/bundle.js") { var stylesheets = new[] {"bootstrap.min.css", "storyteller.css", "font-awesome.min.css", "fixed-data-table.min.css"}; var tags = stylesheets.Select(file => { var path = $"/public/stylesheets/{file}"; return new HtmlTag("link").Attr("rel", "stylesheet").Attr("href", path); }); document.Head.Append(tags); var bundleUrl = devMode ? "http://localhost:3001/client/public/javascript/bundle.js" : bundleName; var scriptTag = new HtmlTag("script").Attr("type", "text/javascript").Attr("src", bundleUrl); document.Body.Append(scriptTag); }
public void GetFileEncodingTest() { var testFiles = new[] { "utf8.yml", "utf8-explicit-bom.yml", "utf16be.yml", "utf16be-explicit-bom.yml", "utf16le.yml", "utf16le-explicit-bom.yml", "utf32be.yml", "utf32be-explicit-bom.yml", "utf32le.yml", "utf32le-explicit-bom.yml" }; foreach (var fileName in testFiles.Select(f => string.Format(Path.Combine("..", "..", "TestData", f)))) using (TextReader reader = new StreamReader(fileName, StringUtil.GetFileEncoding(fileName))) Assert.AreEqual("test", reader.ReadLine()); }
public void TextTokenTest() { var tokens = new[] { new Token( Parser._rule, "<%rule" ), null, new Token( Parser._ident, "Test" ), new Token( Parser._endStatement, "%>" ), new Token( Parser._end, "<%end%>" ) }; var text = string.Join( "", tokens.Select( t => t != null ? t.value : " " ).ToArray() ); var scanner = new global::WolfGenerator.Core.Parsing.Scanner( new MemoryStream( Encoding.UTF8.GetBytes( text ) ) ); foreach (var expectedTokenValue in tokens.Where( s => s != null )) { var actualTokenValue = scanner.Scan(); Assert.That( actualTokenValue.val, Is.EqualTo( expectedTokenValue.value ) ); if (expectedTokenValue.type.HasValue) Assert.That( actualTokenValue.kind, Is.EqualTo( expectedTokenValue.type.Value ), "Wrong kind of parsing token" ); } }
public static bool LoadShaderFromFile(int shaderObj, string fileName, string additionalDefines) { var compileStatus = 0; Sys.DebugLog(GL_LOG_FILENAME, "GL_Loading {0}", fileName); var version = "#version 150\n"; try { if (!string.IsNullOrWhiteSpace(additionalDefines)) { var bufs = new[] {version, additionalDefines, File.ReadAllText(fileName)}; var lengths = bufs.Select(x => x.Length).ToArray(); GL.ShaderSource(shaderObj, 3, bufs, lengths); } else { var bufs = new[] {version, File.ReadAllText(fileName)}; var lengths = bufs.Select(x => x.Length).ToArray(); GL.ShaderSource(shaderObj, 2, bufs, lengths); } } catch { return false; } Sys.DebugLog(GL_LOG_FILENAME, "Source loaded"); GL.CompileShader(shaderObj); Sys.DebugLog(GL_LOG_FILENAME, "Trying to compile"); GL.GetShader(shaderObj, ShaderParameter.CompileStatus, out compileStatus); PrintShaderInfoLog(shaderObj); if(compileStatus != 1) { Sys.DebugLog(GL_LOG_FILENAME, "Compilation failed"); return false; } else { Sys.DebugLog(GL_LOG_FILENAME, "Compilation succeeded"); return true; } }