From 3096c2878e64fb84180e15d6b5e0ff524769d28e Mon Sep 17 00:00:00 2001 From: Ronny Chan Date: Sun, 22 Feb 2015 17:43:04 -0500 Subject: [PATCH 1/3] JSAPI: Correct symbol names (emulatorBridge -> scraper) Signed-off-by: RonnChyran --- 81.patch | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 81.patch diff --git a/81.patch b/81.patch new file mode 100644 index 000000000..0395c9aa6 --- /dev/null +++ b/81.patch @@ -0,0 +1,24 @@ +From 401c0003bf780ef2442f7b13eef65061f6d57201 Mon Sep 17 00:00:00 2001 +From: Ronny Chan +Date: Sun, 22 Feb 2015 17:43:04 -0500 +Subject: [PATCH] JSAPI: Correct symbol names (emulatorBridge -> scraper) + +--- + Snowflake.StandardAjax/StandardAjax.System.cs | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Snowflake.StandardAjax/StandardAjax.System.cs b/Snowflake.StandardAjax/StandardAjax.System.cs +index 9f26ea5..85bdb32 100644 +--- a/Snowflake.StandardAjax/StandardAjax.System.cs ++++ b/Snowflake.StandardAjax/StandardAjax.System.cs +@@ -41,8 +41,8 @@ public IJSResponse GetScrapers(IJSRequest request) + { + IDictionary> response = this.CoreInstance.PluginManager.LoadedScrapers.ToDictionary + ( +- emulatorBridge => emulatorBridge.Key, +- emulatorBridge => emulatorBridge.Value.PluginInfo ++ scraper => scraper.Key, ++ scraper => scraper.Value.PluginInfo + ); + return new JSResponse(request, response); + } \ No newline at end of file From 452089b0d8295dc45ef94fd52c9fe2fa74756da7 Mon Sep 17 00:00:00 2001 From: RonnChyran Date: Sun, 22 Feb 2015 20:14:24 -0500 Subject: [PATCH 2/3] Repo: remove patch file --- 81.patch | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 81.patch diff --git a/81.patch b/81.patch deleted file mode 100644 index 0395c9aa6..000000000 --- a/81.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 401c0003bf780ef2442f7b13eef65061f6d57201 Mon Sep 17 00:00:00 2001 -From: Ronny Chan -Date: Sun, 22 Feb 2015 17:43:04 -0500 -Subject: [PATCH] JSAPI: Correct symbol names (emulatorBridge -> scraper) - ---- - Snowflake.StandardAjax/StandardAjax.System.cs | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Snowflake.StandardAjax/StandardAjax.System.cs b/Snowflake.StandardAjax/StandardAjax.System.cs -index 9f26ea5..85bdb32 100644 ---- a/Snowflake.StandardAjax/StandardAjax.System.cs -+++ b/Snowflake.StandardAjax/StandardAjax.System.cs -@@ -41,8 +41,8 @@ public IJSResponse GetScrapers(IJSRequest request) - { - IDictionary> response = this.CoreInstance.PluginManager.LoadedScrapers.ToDictionary - ( -- emulatorBridge => emulatorBridge.Key, -- emulatorBridge => emulatorBridge.Value.PluginInfo -+ scraper => scraper.Key, -+ scraper => scraper.Value.PluginInfo - ); - return new JSResponse(request, response); - } \ No newline at end of file From d1581c4047eee86ce887c0db4c57dd084b1fc30a Mon Sep 17 00:00:00 2001 From: RonnChyran Date: Sun, 22 Feb 2015 20:22:01 -0500 Subject: [PATCH 3/3] StandardAjax: Fix System namespace file --- Snowflake.StandardAjax/StandardAjax.System.cs | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/Snowflake.StandardAjax/StandardAjax.System.cs b/Snowflake.StandardAjax/StandardAjax.System.cs index b16d4cb0b..3afd9c9f0 100644 --- a/Snowflake.StandardAjax/StandardAjax.System.cs +++ b/Snowflake.StandardAjax/StandardAjax.System.cs @@ -1,8 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Dynamic; +using System.Reflection; using Snowflake.Ajax; using Snowflake.Service; @@ -13,27 +15,49 @@ public partial class StandardAjax [AjaxMethod(MethodPrefix = "System")] public IJSResponse GetEmulatorBridges(IJSRequest request) { - return new JSResponse(request, this.CoreInstance.PluginManager.LoadedEmulators); + IDictionary> response = this.CoreInstance.PluginManager.LoadedEmulators.ToDictionary + ( + emulatorBridge => emulatorBridge.Key, + emulatorBridge => emulatorBridge.Value.PluginInfo + ); + return new JSResponse(request, response); } [AjaxMethod(MethodPrefix = "System")] [AjaxMethodParameter(ParameterName = "platform", ParameterType = AjaxMethodParameterType.StringParameter)] public IJSResponse GetEmulatorBridgesByPlatform(IJSRequest request) { - return new JSResponse(request, this.CoreInstance.PluginManager.LoadedEmulators.Where(bridge => bridge.Value.SupportedPlatforms.Contains(request.GetParameter("platform")))); + IDictionary> response = this.CoreInstance.PluginManager.LoadedEmulators + .Where(bridge => bridge.Value.SupportedPlatforms.Contains(request.GetParameter("platform"))).ToDictionary + ( + emulatorBridge => emulatorBridge.Key, + emulatorBridge => emulatorBridge.Value.PluginInfo + ); + return new JSResponse(request, response); } [AjaxMethod(MethodPrefix = "System")] public IJSResponse GetScrapers(IJSRequest request) { - return new JSResponse(request, this.CoreInstance.PluginManager.LoadedScrapers); + IDictionary> response = this.CoreInstance.PluginManager.LoadedScrapers.ToDictionary + ( + scrapers => scrapers.Key, + scrapers => scrapers.Value.PluginInfo + ); + return new JSResponse(request, response); } [AjaxMethod(MethodPrefix = "System")] [AjaxMethodParameter(ParameterName = "platform", ParameterType = AjaxMethodParameterType.StringParameter)] public IJSResponse GetScrapersByPlatform(IJSRequest request) { - return new JSResponse(request, this.CoreInstance.PluginManager.LoadedScrapers.Where(scraper => scraper.Value.SupportedPlatforms.Contains(request.GetParameter("platform")))); + IDictionary> response = this.CoreInstance.PluginManager.LoadedScrapers + .Where(scraper => scraper.Value.SupportedPlatforms.Contains(request.GetParameter("platform"))).ToDictionary + ( + scraper => scraper.Key, + scraper => scraper.Value.PluginInfo + ); + return new JSResponse(request, response); } [AjaxMethod(MethodPrefix = "System")] @@ -46,7 +70,25 @@ public IJSResponse GetAllPlugins(IJSRequest request) [AjaxMethod(MethodPrefix = "System")] public IJSResponse GetAllAjaxMethods(IJSRequest request) { - return new JSResponse(request, this.CoreInstance.AjaxManager.GlobalNamespace.ToDictionary(ajax => ajax.Key, ajax => ajax.Value.JavascriptMethods)); + List ajaxMethods = new List(); + + foreach (KeyValuePair ajaxNamespace in this.CoreInstance.AjaxManager.GlobalNamespace) + { + foreach (KeyValuePair jsMethod in ajaxNamespace.Value.JavascriptMethods) + { + dynamic methodInfo = new ExpandoObject(); + methodInfo.Namespace = ajaxNamespace.Key; + methodInfo.MethodName = jsMethod.Key; + methodInfo.Parameters = jsMethod.Value.MethodInfo.GetCustomAttributes() + .Select(attr => new Dictionary() { + {"ParameterName", attr.ParameterName}, + {"ParameterType", Enum.GetName(typeof(AjaxMethodParameterType), attr.ParameterType)}, + {"Required", attr.Required} + }); + ajaxMethods.Add(methodInfo); + } + } + return new JSResponse(request, ajaxMethods); } [AjaxMethod(MethodPrefix = "System")]