private static StaveSettings StavesFromJson(dynamic json) { StaveSettings staveSettings; if (Script.Write <bool>("untyped __typeof__(json) == \"string\"")) { staveSettings = new StaveSettings(json); } else if (json.id) { staveSettings = new StaveSettings(json.id); if (json.additionalSettings) { string[] keys2 = Platform.Platform.JsonKeys(json.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2.ToLower()] = json.additionalSettings[key2]; } } } else { return(new StaveSettings("score-tab")); } return(staveSettings); }
private static StaveSettings StavesFromJson(dynamic json) { StaveSettings staveSettings; if (JsContext.@typeof(json) == "string") { staveSettings = new StaveSettings(json); } else if (json.id) { staveSettings = new StaveSettings(json.id); if (json.additionalSettings) { string[] keys2 = Std.JsonKeys(json.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2.ToLower()] = json.additionalSettings[key2]; } } } else { return(new StaveSettings("score-tab")); } return(staveSettings); }
public static void FillFromJson(Settings settings, dynamic json) { if (!json) { return; } if (Std.JsonExists(json, "scale")) { settings.Scale = json.scale; } if (Std.JsonExists(json, "width")) { settings.Width = json.width; } if (Std.JsonExists(json, "height")) { settings.Height = json.height; } if (Std.JsonExists(json, "engine")) { settings.Engine = json.engine; } if (Std.JsonExists(json, "stretchForce")) { settings.StretchForce = json.stretchForce; } if (Std.JsonExists(json, "forcePianoFingering")) { settings.ForcePianoFingering = json.forcePianoFingering; } if (Std.JsonExists(json, "scriptFile")) { settings.ScriptFile = EnsureFullUrl(settings.ScriptFile); settings.ScriptFile = AppendScriptName(json.scriptFile); } else if (HtmlContext.self.document.As <bool>() && HtmlContext.self.window.Member("ALPHATAB_ROOT").As <bool>()) { settings.ScriptFile = HtmlContext.self.window.Member("ALPHATAB_ROOT").As <string>(); settings.ScriptFile = EnsureFullUrl(settings.ScriptFile); settings.ScriptFile = AppendScriptName(settings.ScriptFile); } else { settings.ScriptFile = Environment.ScriptFile; } if (Std.JsonExists(json, "fontDirectory")) { settings.FontDirectory = EnsureFullUrl(json.fontDirectory); } else if (HtmlContext.self.document.As <bool>() && HtmlContext.self.window.Member("ALPHATAB_FONT").As <bool>()) { settings.FontDirectory = HtmlContext.self.window.Member("ALPHATAB_FONT").As <string>(); settings.FontDirectory = EnsureFullUrl(settings.FontDirectory); } else { settings.FontDirectory = settings.ScriptFile; if (!string.IsNullOrEmpty(settings.FontDirectory)) { var lastSlash = settings.FontDirectory.LastIndexOf('/'); if (lastSlash >= 0) { settings.FontDirectory = settings.FontDirectory.Substring(0, lastSlash) + "/Font/"; } } } if (Std.JsonExists(json, "layout")) { if (JsContext.@typeof(json.layout) == "string") { settings.Layout.Mode = json.layout; } else { if (json.layout.mode) { settings.Layout.Mode = json.layout.mode; } if (json.layout.additionalSettings) { string[] keys = Std.JsonKeys(json.layout.additionalSettings); foreach (var key in keys) { settings.Layout.AdditionalSettings[key] = json.layout.additionalSettings[key]; } } } } if (Std.JsonExists(json, "staves")) { var val = json.staves; if (JsContext.@typeof(val) == "string") { settings.Staves = new StaveSettings(val); } else { if (val.id) { var staveSettings = new StaveSettings(val.id); if (val.additionalSettings) { string[] keys2 = Std.JsonKeys(val.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2] = val.additionalSettings[key2]; } } settings.Staves = staveSettings; } } } }
public static void FillFromJson(Settings settings, dynamic json) { if (!json) { return; } if (Std.JsonExists(json, "scale")) { settings.Scale = json.scale; } if (Std.JsonExists(json, "width")) { settings.Width = json.width; } if (Std.JsonExists(json, "height")) { settings.Height = json.height; } if (Std.JsonExists(json, "engine")) { settings.Engine = json.engine; } if (Std.JsonExists(json, "stretchForce")) { settings.StretchForce = json.stretchForce; } if (Std.JsonExists(json, "forcePianoFingering")) { settings.ForcePianoFingering = json.forcePianoFingering; } if (Std.JsonExists(json, "layout")) { if (JsContext.@typeof(json.layout) == "string") { settings.Layout.Mode = json.layout; } else { if (json.layout.mode) { settings.Layout.Mode = json.layout.mode; } if (json.layout.additionalSettings) { string[] keys = Std.JsonKeys(json.layout.additionalSettings); foreach (var key in keys) { settings.Layout.AdditionalSettings[key] = json.layout.additionalSettings[key]; } } } } if (Std.JsonExists(json, "staves")) { settings.Staves = new FastList <StaveSettings>(); string[] keys = Std.JsonKeys(json.staves); foreach (var key in keys) { var val = json.staves[key]; if (JsContext.@typeof(val) == "string") { settings.Staves.Add(new StaveSettings(val)); } else { if (val.id) { var staveSettings = new StaveSettings(val.id); if (val.additionalSettings) { string[] keys2 = Std.JsonKeys(val.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2] = val.additionalSettings[key2]; } } settings.Staves.Add(staveSettings); } } } } }
public static Settings FromJson(dynamic json) { if (Std.InstanceOf <Settings>(json)) { return((Settings)json); } var settings = Defaults; if (!json) { return(settings); } if (JsonExists(json, "scale")) { settings.Scale = json.scale; } if (JsonExists(json, "width")) { settings.Width = json.width; } if (JsonExists(json, "height")) { settings.Height = json.height; } if (JsonExists(json, "engine")) { settings.Engine = json.engine; } if (JsonExists(json, "layout")) { if (JsContext.@typeof(json.layout) == "string") { settings.Layout.Mode = json.layout; } else { if (json.layout.mode) { settings.Layout.Mode = json.layout.mode; } if (json.layout.additionalSettings) { string[] keys = JsonKeys(json.layout.additionalSettings); foreach (var key in keys) { settings.Layout.AdditionalSettings[key] = json.layout.additionalSettings[key]; } } } } if (JsonExists(json, "staves")) { settings.Staves = new FastList <StaveSettings>(); string[] keys = JsonKeys(json.staves); foreach (var key in keys) { var val = json.staves[key]; if (JsContext.@typeof(val) == "string") { settings.Staves.Add(new StaveSettings(val)); } else { if (val.id) { var staveSettings = new StaveSettings(val.id); if (val.additionalSettings) { string[] keys2 = JsonKeys(val.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2] = val.additionalSettings[key2]; } } settings.Staves.Add(staveSettings); } } } } return(settings); }
public static void FillFromJson(Settings settings, dynamic json) { if (!json) { return; } if (Std.JsonExists(json, "scale")) { settings.Scale = json.scale; } if (Std.JsonExists(json, "width")) { settings.Width = json.width; } if (Std.JsonExists(json, "height")) { settings.Height = json.height; } if (Std.JsonExists(json, "engine")) { settings.Engine = json.engine; } if (Std.JsonExists(json, "stretchForce")) { settings.StretchForce = json.stretchForce; } if (Std.JsonExists(json, "forcePianoFingering")) { settings.ForcePianoFingering = json.forcePianoFingering; } if (Std.JsonExists(json, "atRoot")) { settings.ScriptFile = json.atRoot; // append script name if (!settings.ScriptFile.EndsWith(".js")) { if (!settings.ScriptFile.EndsWith("/")) { settings.ScriptFile += "/"; } settings.ScriptFile += "AlphaTab.js"; } if (!settings.ScriptFile.StartsWith("http") && !settings.ScriptFile.StartsWith("https")) { var root = new StringBuilder(); root.Append(HtmlContext.window.location.protocol); root.Append("//"); root.Append(HtmlContext.window.location.hostname); if (HtmlContext.window.location.port.As <bool>()) { root.Append(":"); root.Append(HtmlContext.window.location.port); } root.Append(settings.ScriptFile); settings.ScriptFile = root.ToString(); } } else { settings.ScriptFile = Environment.ScriptFile; } if (Std.JsonExists(json, "layout")) { if (JsContext.@typeof(json.layout) == "string") { settings.Layout.Mode = json.layout; } else { if (json.layout.mode) { settings.Layout.Mode = json.layout.mode; } if (json.layout.additionalSettings) { string[] keys = Std.JsonKeys(json.layout.additionalSettings); foreach (var key in keys) { settings.Layout.AdditionalSettings[key] = json.layout.additionalSettings[key]; } } } } if (Std.JsonExists(json, "staves")) { settings.Staves = new FastList <StaveSettings>(); string[] keys = Std.JsonKeys(json.staves); foreach (var key in keys) { var val = json.staves[key]; if (JsContext.@typeof(val) == "string") { settings.Staves.Add(new StaveSettings(val)); } else { if (val.id) { var staveSettings = new StaveSettings(val.id); if (val.additionalSettings) { string[] keys2 = Std.JsonKeys(val.additionalSettings); foreach (var key2 in keys2) { staveSettings.AdditionalSettings[key2] = val.additionalSettings[key2]; } } settings.Staves.Add(staveSettings); } } } } }