mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +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;
|
string rpc = string.Empty;
|
||||||
if (Parameters != null && Parameters.Length > 0)
|
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) + "]";
|
parameters = parameters.Substring(0, parameters.Length - 1) + "]";
|
||||||
rpc = string.Format(@"{{\""method\"":\""{0}\"",\""parameters\"":{1}", Method, parameters);
|
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 (parameter == null) {
|
||||||
if (paramter is string)
|
return "null";
|
||||||
{
|
|
||||||
return string.Format(@"\""{0}\""", RepalceEscapes(paramter.ToString()));
|
|
||||||
}
|
}
|
||||||
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
|
return str.Replace(@"\", @"\\") //Escapes in ProcessStartInfo
|
||||||
.Replace(@"\", @"\\") //Escapes itself when passed to client
|
.Replace(@"\", @"\\") //Escapes itself when passed to client
|
||||||
|
|||||||
Reference in New Issue
Block a user