mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
ContextMenu 1: Rename #1366
This commit is contained in:
committed by
bao-qian
parent
2f3a2d495a
commit
de12208d4a
@@ -56,7 +56,7 @@ namespace Wox.Core.Plugin
|
||||
string rpc = string.Empty;
|
||||
if (Parameters != null && Parameters.Length > 0)
|
||||
{
|
||||
string parameters = Parameters.Aggregate("[", (current, o) => current + (GetParamterByType(o) + ","));
|
||||
string parameters = Parameters.Aggregate("[", (current, o) => current + (GetParameterByType(o) + ","));
|
||||
parameters = parameters.Substring(0, parameters.Length - 1) + "]";
|
||||
rpc = string.Format(@"{{\""method\"":\""{0}\"",\""parameters\"":{1}", Method, parameters);
|
||||
}
|
||||
@@ -69,25 +69,27 @@ namespace Wox.Core.Plugin
|
||||
|
||||
}
|
||||
|
||||
private string GetParamterByType(object paramter)
|
||||
private string GetParameterByType(object parameter)
|
||||
{
|
||||
|
||||
if (paramter is string)
|
||||
{
|
||||
return string.Format(@"\""{0}\""", RepalceEscapes(paramter.ToString()));
|
||||
if (parameter == null) {
|
||||
return "null";
|
||||
}
|
||||
if (paramter is int || paramter is float || paramter is double)
|
||||
if (parameter is string)
|
||||
{
|
||||
return string.Format(@"{0}", paramter);
|
||||
return string.Format(@"\""{0}\""", ReplaceEscapes(parameter.ToString()));
|
||||
}
|
||||
if (paramter is bool)
|
||||
if (parameter is int || parameter is float || parameter is double)
|
||||
{
|
||||
return string.Format(@"{0}", paramter.ToString().ToLower());
|
||||
return string.Format(@"{0}", parameter);
|
||||
}
|
||||
return paramter.ToString();
|
||||
if (parameter is bool)
|
||||
{
|
||||
return string.Format(@"{0}", parameter.ToString().ToLower());
|
||||
}
|
||||
return parameter.ToString();
|
||||
}
|
||||
|
||||
private string RepalceEscapes(string str)
|
||||
private string ReplaceEscapes(string str)
|
||||
{
|
||||
return str.Replace(@"\", @"\\") //Escapes in ProcessStartInfo
|
||||
.Replace(@"\", @"\\") //Escapes itself when passed to client
|
||||
|
||||
Reference in New Issue
Block a user