diff --git a/MapsInMyFolder.Common/Collectif.cs b/MapsInMyFolder.Common/Collectif.cs index 6c2c1b4..3f7d6c7 100644 --- a/MapsInMyFolder.Common/Collectif.cs +++ b/MapsInMyFolder.Common/Collectif.cs @@ -1,25 +1,25 @@ -using System; +using Jint; +using MapsInMyFolder.Commun; +using NetVips; +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Net.Http; +using System.Reflection; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Windows; using System.Windows.Controls; using System.Windows.Documents; -using System.Windows.Media.Imaging; -using System.Reflection; -using System.Windows; +using System.Windows.Input; using System.Windows.Media; -using System.Text.RegularExpressions; using System.Windows.Media.Animation; -using System.Windows.Input; -using MapsInMyFolder.Commun; -using Newtonsoft.Json; -using NetVips; -using Jint; +using System.Windows.Media.Imaging; namespace MapsInMyFolder.Commun { @@ -57,27 +57,14 @@ public static class Collectif public static class GetUrl { public enum InvokeFunction { getTile, getPreview, getPreviewFallback } - public static string FromTileXYZ(string urlbase, int Tilex, int Tiley, int z, int LayerID, InvokeFunction InvokeFunction) + + public static (Dictionary DefaultCallValue, Dictionary ResultCallValue) CallFunctionAndGetResult(string urlbase, string TileComputationScript, int Tilex, int Tiley, int z, int LayerID, InvokeFunction InvokeFunction) { if (LayerID == -1) { - return urlbase; + return (null, null); } - Layers calque = Layers.GetLayerById(LayerID); - if (calque is null) - { - return string.Empty; - } - string finalurl; - if (string.IsNullOrEmpty(urlbase)) - { - finalurl = calque.class_tile_url; - } - else - { - finalurl = urlbase; - } var location_topleft = TileToCoordonnees(Tilex, Tiley, z); var location_bottomright = TileToCoordonnees(Tilex + 1, Tiley + 1, z); var location = GetCenterBetweenTwoPoints(location_topleft, location_bottomright); @@ -99,16 +86,14 @@ public static string FromTileXYZ(string urlbase, int Tilex, int Tiley, int z, in { "layerid", LayerID.ToString() }, { "url", urlbase }, }; - //Jint.Native.JsValue JavascriptMainResult = Commun.Javascript.ExecuteScript("function main() { var js = new TheType(); log(js.TestDoubleReturn(0,0)); return args; }", argument); - string TileComputationScript = calque.class_tilecomputationscript; if (!string.IsNullOrEmpty(TileComputationScript)) { Jint.Native.JsValue JavascriptMainResult = null; try { - JavascriptMainResult = Javascript.ExecuteScript(TileComputationScript, argument, LayerID, InvokeFunction); + JavascriptMainResult = Javascript.ExecuteScript(TileComputationScript, new Dictionary(argument), LayerID, InvokeFunction); } catch (Exception ex) { @@ -119,40 +104,73 @@ public static string FromTileXYZ(string urlbase, int Tilex, int Tiley, int z, in object JavascriptMainResultObject = JavascriptMainResult.ToObject(); var JavascriptMainResultJson = JsonConvert.SerializeObject(JavascriptMainResultObject); var JavascriptMainResultDictionary = JsonConvert.DeserializeObject>(JavascriptMainResultJson); + return (argument, JavascriptMainResultDictionary); + } + } + return (null, null); + + } + - if (JavascriptMainResultDictionary.TryGetValue("url", out string urlResult)) + public static string FromTileXYZ(string urlbase, int Tilex, int Tiley, int z, int LayerID, InvokeFunction InvokeFunction) + { + if (LayerID == -1) + { + return urlbase; + } + + Layers calque = Layers.GetLayerById(LayerID); + if (calque is null) + { + return string.Empty; + } + string TileComputationScript = calque.class_tilecomputationscript; + var ValuesDictionnary = CallFunctionAndGetResult(urlbase, TileComputationScript, Tilex, Tiley, z, LayerID, InvokeFunction); + if (ValuesDictionnary.ResultCallValue is null) + { + return string.Empty; + } + + string finalurl; + if (string.IsNullOrEmpty(urlbase)) + { + finalurl = calque.class_tile_url; + } + else + { + finalurl = urlbase; + } + if (ValuesDictionnary.ResultCallValue.TryGetValue("url", out string urlResult)) + { + if (!string.IsNullOrEmpty(urlResult)) + { + finalurl = urlResult; + } + } + + foreach (var JavascriptReplacementVar in ValuesDictionnary.ResultCallValue) + { + string replacementValue = string.Empty; + try + { + if (JavascriptReplacementVar.Value is null) { - if (!string.IsNullOrEmpty(urlResult)) - { - finalurl = urlResult; - } + replacementValue = "null"; } - - foreach (var JavascriptReplacementVar in JavascriptMainResultDictionary) + else { - string replacementValue = string.Empty; - try - { - if (JavascriptReplacementVar.Value is null) - { - replacementValue = "null"; - } - else - { - replacementValue = JavascriptReplacementVar.Value; - } - } - catch (Exception ex) - { - Debug.WriteLine(ex.Message); - replacementValue = "null"; - } - finally - { - finalurl = finalurl.Replace("{" + JavascriptReplacementVar.Key + "}", replacementValue); - } + replacementValue = JavascriptReplacementVar.Value; } } + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + replacementValue = "null"; + } + finally + { + finalurl = finalurl.Replace("{" + JavascriptReplacementVar.Key + "}", replacementValue); + } } return finalurl; } @@ -234,13 +252,15 @@ public static void GetAllManifestResourceNames() public static string ReadResourceString(string pathWithSlash) { - Stream stream = ReadResourceStream(pathWithSlash); - string return_rsx = String.Empty; - using (StreamReader reader = new StreamReader(stream, Encoding.UTF8, true)) + using (Stream stream = ReadResourceStream(pathWithSlash)) { - return_rsx = reader.ReadToEnd(); + string return_rsx = String.Empty; + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8, true)) + { + return_rsx = reader.ReadToEnd(); + } + return return_rsx; } - return return_rsx; } public static Stream ReadResourceStream(string pathWithSlash) @@ -458,7 +478,7 @@ public static byte[] GetEmptyImageBufferFromText(string BitmapErrorsMessage) } lock (Locker) { - using (NetVips.Image text = NetVips.Image.Text(WordWrap(BitmapErrorsMessage, 20), null, null, null, NetVips.Enums.Align.Centre, null, 100, true, 5, null)) + using (NetVips.Image text = NetVips.Image.Text(WordWrap(BitmapErrorsMessage, 20), null, null, null, NetVips.Enums.Align.Centre, null, 100, 5, null)) { int offsetX = (int)Math.Floor((double)(border_tile_size - text.Width) / 2); int offsetY = (int)Math.Floor((double)(border_tile_size - text.Height) / 2); @@ -790,19 +810,18 @@ public static void LockPreviousUndo(TextBox uIElement) public static void InsertTextAtCaretPosition(ICSharpCode.AvalonEdit.TextEditor TextBox, string text) { + int CaretIndex = TextBox.CaretOffset; if (TextBox.SelectionLength == 0) { - int CaretIndex = TextBox.CaretOffset; TextBox.TextArea.Document.Insert(CaretIndex, text); - - TextBox.CaretOffset = CaretIndex + text.Length; } else { TextBox.SelectedText = text; - TextBox.CaretOffset += TextBox.SelectedText.Length; TextBox.SelectionLength = 0; } + + TextBox.CaretOffset = Math.Min(TextBox.Text.Length, CaretIndex + text.Length); } public static void TextEditorCursorPositionChanged(ICSharpCode.AvalonEdit.TextEditor textEditor, Grid grid, ScrollViewer scrollViewer, int MarginTop = 25) @@ -898,7 +917,7 @@ public static List FindVisualChildren(UIElement obj, ListThe first parent item that matches the submitted type parameter. /// If not matching item can be found, /// a null parent is being returned. - public static T FindChild(DependencyObject parent, string childName) + public static T FindChildByName(DependencyObject parent, string childName) where T : DependencyObject { // Confirm parent and childName are valid. @@ -915,7 +934,7 @@ public static T FindChild(DependencyObject parent, string childName) if (childType == null) { // recursively drill down the tree - foundChild = FindChild(child, childName); + foundChild = FindChildByName(child, childName); // If the child is found, break so we do not overwrite the found child. if (foundChild != null) break; @@ -942,6 +961,23 @@ public static T FindChild(DependencyObject parent, string childName) return foundChild; } + public static T FindChild(DependencyObject parent) where T : DependencyObject + { + if (parent == null) + { + return null; + } + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) + { + var child = VisualTreeHelper.GetChild(parent, i); + var result = (child as T) ?? FindChild(child); + if (result != null) + { + return result; + } + } + return null; + } public static int CheckIfInputValueHaveChange(UIElement SourcePanel) { @@ -1010,7 +1046,7 @@ public static int CheckIfInputValueHaveChange(UIElement SourcePanel) BlackPearl.Controls.CoreLibrary.MultiSelectCombobox MultiSelectCombobox = (BlackPearl.Controls.CoreLibrary.MultiSelectCombobox)element; if (MultiSelectCombobox.SelectedItems != null && MultiSelectCombobox.SelectedItems.Count > 0) { - + hachCode = string.Join(";", MultiSelectCombobox.SelectedValues("EnglishName")).GetHashCode(); } else diff --git a/MapsInMyFolder.Common/Country.cs b/MapsInMyFolder.Common/Country.cs index 3103f57..9c0d932 100644 --- a/MapsInMyFolder.Common/Country.cs +++ b/MapsInMyFolder.Common/Country.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace MapsInMyFolder.Commun { diff --git a/MapsInMyFolder.Common/Database.cs b/MapsInMyFolder.Common/Database.cs index 9edc12e..651d0f9 100644 --- a/MapsInMyFolder.Common/Database.cs +++ b/MapsInMyFolder.Common/Database.cs @@ -49,12 +49,12 @@ public static async Task DB_AskDownload(bool force_download = false) } } - private static void CreateEmptyDatabase(string database_pathname) + private static async void CreateEmptyDatabase(string database_pathname) { SQLiteConnection.CreateFile(database_pathname); DB_CreateTables(database_pathname); RefreshPanels.Invoke(null, EventArgs.Empty); - Database.CheckIfNewerVersionAvailable(); + await Database.CheckIfNewerVersionAvailable(); } private static async Task DB_DownloadFile(string database_url, string database_pathname) @@ -333,7 +333,7 @@ public static SQLiteConnection DB_CreateTables(string datasource) return null; } SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand(); - const string commande_arg = "'ID' INTEGER UNIQUE, 'NOM' TEXT DEFAULT '', 'DESCRIPTION' TEXT DEFAULT '', 'CATEGORIE' TEXT DEFAULT '','PAYS' TEXT DEFAULT '', 'IDENTIFIANT' TEXT DEFAULT '', 'TILE_URL' TEXT DEFAULT '','TILE_FALLBACK_URL' TEXT DEFAULT '', 'MIN_ZOOM' INTEGER DEFAULT 0, 'MAX_ZOOM' INTEGER DEFAULT 0, 'FORMAT' TEXT DEFAULT 'jpeg', 'SITE' TEXT DEFAULT '', 'SITE_URL' TEXT DEFAULT '', 'TILE_SIZE' INTEGER DEFAULT 256, 'FAVORITE' INTEGER DEFAULT 0, 'TILECOMPUTATIONSCRIPT' TEXT DEFAULT '','VISIBILITY' TEXT DEFAULT 'Visible' ,'SPECIALSOPTIONS' TEXT DEFAULT '','RECTANGLES' TEXT DEFAULT '', 'VERSION' INTEGER DEFAULT 1, 'HAS_SCALE' INTEGER DEFAULT 0"; + const string commande_arg = "'ID' INTEGER UNIQUE, 'NOM' TEXT DEFAULT '', 'DESCRIPTION' TEXT DEFAULT '', 'CATEGORIE' TEXT DEFAULT '','PAYS' TEXT DEFAULT '', 'IDENTIFIANT' TEXT DEFAULT '', 'TILE_URL' TEXT DEFAULT '','TILE_FALLBACK_URL' TEXT DEFAULT '', 'MIN_ZOOM' INTEGER DEFAULT '', 'MAX_ZOOM' INTEGER DEFAULT '', 'FORMAT' TEXT DEFAULT '', 'SITE' TEXT DEFAULT '', 'SITE_URL' TEXT DEFAULT '', 'TILE_SIZE' INTEGER DEFAULT '', 'FAVORITE' INTEGER DEFAULT 0, 'TILECOMPUTATIONSCRIPT' TEXT DEFAULT '','VISIBILITY' TEXT DEFAULT '' ,'SPECIALSOPTIONS' TEXT DEFAULT '','RECTANGLES' TEXT DEFAULT '', 'VERSION' INTEGER DEFAULT 1, 'HAS_SCALE' INTEGER DEFAULT 1"; sqlite_cmd.CommandText = $@" CREATE TABLE IF NOT EXISTS 'CUSTOMSLAYERS' ({commande_arg}); CREATE TABLE IF NOT EXISTS 'LAYERS' ({commande_arg},PRIMARY KEY('ID' AUTOINCREMENT)); @@ -418,13 +418,15 @@ public static void DB_Download_Delete(int bdid) } } - public static async void CheckIfNewerVersionAvailable() + public static async Task CheckIfNewerVersionAvailable() { (bool IsNewVersionAvailable, int NewVersionNumber) NewVersion = await CompareVersion(); if (NewVersion.IsNewVersionAvailable) { NewUpdateFoundEvent(null, NewVersion.NewVersionNumber); + return true; } + return false; } private static async Task<(bool IsNewVersionAvailable, int NewVersionNumber)> CompareVersion() diff --git a/MapsInMyFolder.Common/DiffMatchPatch.cs b/MapsInMyFolder.Common/DiffMatchPatch.cs index 3ae67a0..9c59455 100644 --- a/MapsInMyFolder.Common/DiffMatchPatch.cs +++ b/MapsInMyFolder.Common/DiffMatchPatch.cs @@ -104,7 +104,7 @@ public override bool Equals(Object obj) // If parameter cannot be cast to Diff return false. Diff p = obj as Diff; - if ((System.Object)p == null) + if (p == null) { return false; } @@ -718,7 +718,7 @@ private string diff_linesToCharsMunge(string text, List lineArray, if (lineHash.ContainsKey(line)) { - chars.Append(((char)(int)lineHash[line])); + chars.Append(((char)lineHash[line])); } else { diff --git a/MapsInMyFolder.Common/Extensions.cs b/MapsInMyFolder.Common/Extensions.cs index c17e06c..eddb16d 100644 --- a/MapsInMyFolder.Common/Extensions.cs +++ b/MapsInMyFolder.Common/Extensions.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; @@ -150,6 +149,25 @@ public static bool ContainsOneOrMore(this IEnumerable BaseArray, IEnumer return false; } + public static string Replace(this string Texte, IEnumerable oldCharArray, string newString) + { + foreach (char SearchStr in oldCharArray) + { + Texte = Texte.Replace(SearchStr.ToString(), newString); + } + return Texte; + } + + public static string ReplaceLoop(this string Texte, string oldString, string newString) + { + while (Texte.Contains(oldString)) + { + Texte = Texte.Replace(oldString, newString); + } + return Texte; + } + + } } diff --git a/MapsInMyFolder.Common/GetGithubAssets.cs b/MapsInMyFolder.Common/GetGithubAssets.cs index 0beea03..8876be8 100644 --- a/MapsInMyFolder.Common/GetGithubAssets.cs +++ b/MapsInMyFolder.Common/GetGithubAssets.cs @@ -1,10 +1,9 @@ -using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; -using System.Linq; -using Newtonsoft.Json; -using System.Net; using System.Diagnostics; -using Newtonsoft.Json.Linq; +using System.Linq; namespace MapsInMyFolder.Commun { diff --git a/MapsInMyFolder.Common/JSBeautify.cs b/MapsInMyFolder.Common/JSBeautify.cs index b64f02a..6e2367a 100644 --- a/MapsInMyFolder.Common/JSBeautify.cs +++ b/MapsInMyFolder.Common/JSBeautify.cs @@ -4,10 +4,10 @@ // using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Collections; using System.Text.RegularExpressions; namespace MapsInMyFolder.Commun @@ -41,12 +41,12 @@ public class JSBeautify private void trim_output() { - while ((output.Length>0) && ((output[output.Length-1]==' ')||(output[output.Length-1].ToString()==indent_string))) + while ((output.Length > 0) && ((output[output.Length - 1] == ' ') || (output[output.Length - 1].ToString() == indent_string))) { - output.Remove(output.Length-1,1); + output.Remove(output.Length - 1, 1); } } - + private void print_newline(bool? ignore_repeated) { ignore_repeated = ignore_repeated ?? true; @@ -79,7 +79,7 @@ private void print_space() } } - + private void print_token() { output.Append(token_text); @@ -98,9 +98,9 @@ private void unindent() private void remove_indent() { - if ((output.Length>0) && (output[output.Length-1].ToString()==indent_string)) + if ((output.Length > 0) && (output[output.Length - 1].ToString() == indent_string)) { - output.Remove(output.Length-1,1); + output.Remove(output.Length - 1, 1); } } @@ -119,7 +119,7 @@ private void restore_mode() private bool in_array(object what, ArrayList arr) { return arr.Contains(what); - + } private bool is_ternary_op() @@ -226,9 +226,9 @@ private string[] get_next_token(ref int parser_pos) break; } } - - - if ((parser_pos!=input.Length) && (Regex.IsMatch(c,"^[0-9]+[Ee]$")) && ((input[parser_pos] == '-') || (input[parser_pos]=='+'))) + + + if ((parser_pos != input.Length) && (Regex.IsMatch(c, "^[0-9]+[Ee]$")) && ((input[parser_pos] == '-') || (input[parser_pos] == '+'))) { var sign = input[parser_pos]; parser_pos++; @@ -252,104 +252,131 @@ private string[] get_next_token(ref int parser_pos) } if ((c == "(") || (c == "[")) - return new string[] {c,"TK_START_EXPR"}; + return new string[] { c, "TK_START_EXPR" }; - if (c == ")" || c == "]") { - return new string[] {c, "TK_END_EXPR"}; + if (c == ")" || c == "]") + { + return new string[] { c, "TK_END_EXPR" }; } - if (c == "{") { - return new string[] {c, "TK_START_BLOCK"}; + if (c == "{") + { + return new string[] { c, "TK_START_BLOCK" }; } - if (c == "}") { - return new string[] {c, "TK_END_BLOCK"}; + if (c == "}") + { + return new string[] { c, "TK_END_BLOCK" }; } - if (c == ";") { - return new string[] {c, "TK_SEMICOLON"}; + if (c == ";") + { + return new string[] { c, "TK_SEMICOLON" }; } - if (c=="/") { + if (c == "/") + { var comment = ""; - if (input[parser_pos]=='*') { + if (input[parser_pos] == '*') + { parser_pos++; - if (parser_pos'\0') && (input[parser_pos+1]=='/') && (parser_pos '\0') && (input[parser_pos + 1] == '/') && (parser_pos < input.Length))) { - comment+=input[parser_pos]; + comment += input[parser_pos]; parser_pos++; - if (parser_pos>=input.Length) { + if (parser_pos >= input.Length) + { break; } } } - - parser_pos+=2; - return new string[] { "/*"+comment+"*/", "TK_BLOCK_COMMENT"}; - } - if (input[parser_pos]=='/') { + parser_pos += 2; + return new string[] { "/*" + comment + "*/", "TK_BLOCK_COMMENT" }; + } + + if (input[parser_pos] == '/') + { comment = c; - while ((input[parser_pos]!='\x0d') && (input[parser_pos]!='\x0a')) { - comment+=input[parser_pos]; + while ((input[parser_pos] != '\x0d') && (input[parser_pos] != '\x0a')) + { + comment += input[parser_pos]; parser_pos++; - if (parser_pos>=input.Length){ + if (parser_pos >= input.Length) + { break; } } parser_pos++; - if (wanted_newline){ + if (wanted_newline) + { print_newline(null); } - return new string[] {comment,"TK_COMMENT"}; + return new string[] { comment, "TK_COMMENT" }; } } - if ( (c=="'") || (c=="\"") || ((c=="/") - && ((last_type=="TK_WORD" && last_text=="return") || ((last_type=="TK_START_EXPR") || (last_type=="TK_START_BLOCK") || (last_type=="TK_END_BLOCK") - || (last_type=="TK_OPERATOR") || (last_type=="TK_EOF") || (last_type=="TK_SEMICOLON")))) - ) { + if ((c == "'") || (c == "\"") || ((c == "/") + && ((last_type == "TK_WORD" && last_text == "return") || ((last_type == "TK_START_EXPR") || (last_type == "TK_START_BLOCK") || (last_type == "TK_END_BLOCK") + || (last_type == "TK_OPERATOR") || (last_type == "TK_EOF") || (last_type == "TK_SEMICOLON")))) + ) + { var sep = c; var esc = false; var resulting_string = c; - if (parser_pos=input.Length) { - return new string[] { resulting_string, "TK_STRING"}; + if (parser_pos >= input.Length) + { + return new string[] { resulting_string, "TK_STRING" }; } - } + } } - else { - while ((esc) || (input[parser_pos].ToString()!=sep)) { + else + { + while ((esc) || (input[parser_pos].ToString() != sep)) + { resulting_string += input[parser_pos]; - if (!esc) { - esc = input[parser_pos]=='\\'; - } else { - esc=false; + if (!esc) + { + esc = input[parser_pos] == '\\'; + } + else + { + esc = false; } parser_pos++; - if (parser_pos>=input.Length){ - return new string[] {resulting_string,"TK_STRING"}; + if (parser_pos >= input.Length) + { + return new string[] { resulting_string, "TK_STRING" }; } } } @@ -359,61 +386,75 @@ private string[] get_next_token(ref int parser_pos) resulting_string += sep; - if (sep == "/") { + if (sep == "/") + { // regexps may have modifiers /regexp/MOD , so fetch those, too - while ((parser_pos < input.Length) && (wordchar.Contains(input[parser_pos]))) { + while ((parser_pos < input.Length) && (wordchar.Contains(input[parser_pos]))) + { resulting_string += input[parser_pos]; parser_pos += 1; } } - return new string [] {resulting_string, "TK_STRING"}; + return new string[] { resulting_string, "TK_STRING" }; } - if (c == "#") { + if (c == "#") + { var sharp = "#"; - if ((parser_pos < input.Length) && (digits.Contains(input[parser_pos]))) { - do { + if ((parser_pos < input.Length) && (digits.Contains(input[parser_pos]))) + { + do + { c = input[parser_pos].ToString(); sharp += c; parser_pos += 1; - } while ((parser_pos < input.Length ) && (c != "#") && (c != "=")); - if (c == "#") { - return new string[] {sharp, "TK_WORD"};; - } else { - return new string[] {sharp, "TK_OPERATOR"};; + } while ((parser_pos < input.Length) && (c != "#") && (c != "=")); + if (c == "#") + { + return new string[] { sharp, "TK_WORD" }; ; + } + else + { + return new string[] { sharp, "TK_OPERATOR" }; ; } } } - if ((c == "<") && (input.Substring(parser_pos - 1, 3) == "")) { + if ((c == "-") && (input.Substring(parser_pos - 1, 2) == "-->")) + { parser_pos += 2; - if (wanted_newline) { + if (wanted_newline) + { print_newline(null); } - return new string[] {"-->", "TK_COMMENT"}; + return new string[] { "-->", "TK_COMMENT" }; } - if (punct.Contains(c)) { - while ((parser_pos < input.Length) && (punct.Contains(c + input[parser_pos]))) { + if (punct.Contains(c)) + { + while ((parser_pos < input.Length) && (punct.Contains(c + input[parser_pos]))) + { c += input[parser_pos]; parser_pos += 1; - if (parser_pos >= input.Length) { + if (parser_pos >= input.Length) + { break; } } - return new string[] {c, "TK_OPERATOR"}; + return new string[] { c, "TK_OPERATOR" }; } - return new string[] {c, "TK_UNKNOWN"}; + return new string[] { c, "TK_UNKNOWN" }; } @@ -431,7 +472,7 @@ public string GetResult() { output.AppendLine().AppendLine(""); } - + return output.ToString(); } @@ -445,20 +486,21 @@ public JSBeautify(string js_source_text, JSBeautifyOptions options) output = new StringBuilder(); modes = new Stack(); - + indent_string = ""; - - while (opt_indent_size > 0) { + + while (opt_indent_size > 0) + { indent_string += opt_indent_char; opt_indent_size -= 1; } indent_level = opt_indent_level; - - input = js_source_text.Replace("",""); + + input = js_source_text.Replace("", ""); if (input.Length != js_source_text.Length) { output.AppendLine("