Browse Source

遗漏的提交

loki.wu 2 years ago
parent
commit
3263c5a070
1 changed files with 38 additions and 0 deletions
  1. 38 0
      fis/Win/JsContentConvert.cs

+ 38 - 0
fis/Win/JsContentConvert.cs

@@ -0,0 +1,38 @@
+using fis.Utilities;
+using System.Collections.Generic;
+
+
+namespace fis.Win
+{
+    internal class JsContentConvert
+    {
+        private const string _notificationName = "externalNotification";
+
+        public static string GetExcuteJsContent(TargetMethodName targetMethodName, List<string> arguments)
+        {
+            string callString = _notificationName + "(";
+            if (arguments != null)
+            {
+                string comma = ", ";
+                var argumentsStr = "";
+                int index = 0;
+                foreach (var e in arguments)
+                {
+                    if (index == arguments.Count - 1)
+                    {
+                        argumentsStr += e;
+                    }
+                    else
+                    {
+                        argumentsStr += e + "&";
+                    }
+                    index++;
+                }
+                var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
+                callString += (int)targetMethodName + comma + escaped + comma + "";
+            }
+            callString += ");";
+            return callString;
+        }
+    }
+}