You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/01/17 00:01:51 UTC

[2/6] git commit: CommandFactory.CreateByServiceName takes new optional string value which can be the fully qualified class name, or just an alias class name to prevent ambiguity

CommandFactory.CreateByServiceName takes new optional string value which can be the fully qualified class name, or just an alias class name to prevent ambiguity


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/af804749
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/af804749
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/af804749

Branch: refs/heads/master
Commit: af80474988f1eee61684c3ee9f37b96d9aa398a6
Parents: 4265d0a
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu Jan 16 14:21:33 2014 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu Jan 16 14:21:33 2014 -0800

----------------------------------------------------------------------
 wp8/template/cordovalib/CommandFactory.cs  | 17 ++++++++++++++---
 wp8/template/cordovalib/NativeExecution.cs |  4 ++--
 2 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/af804749/wp8/template/cordovalib/CommandFactory.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/CommandFactory.cs b/wp8/template/cordovalib/CommandFactory.cs
index 974ee79..aedd3a4 100644
--- a/wp8/template/cordovalib/CommandFactory.cs
+++ b/wp8/template/cordovalib/CommandFactory.cs
@@ -52,7 +52,10 @@ namespace WPCordovaClassLib.Cordova
         /// </summary>
         /// <param name="service">Command class name, for example Device or Notification</param>
         /// <returns>Command class instance or null</returns>
-        public static BaseCommand CreateByServiceName(string service)
+        /// alias can be used as a namespace which is resolved + service
+        /// or it can be the fully qualified classname
+        /// or the classname in the current assembly
+        public static BaseCommand CreateByServiceName(string service, string alias="")
         {
 
             if (string.IsNullOrEmpty(service))
@@ -62,9 +65,18 @@ namespace WPCordovaClassLib.Cordova
 
             if (!commandMap.ContainsKey(service))
             {
-
                 Type t = Type.GetType(BaseCommandNamespacePrefix + service);
 
+                if (t == null && !string.IsNullOrEmpty(alias))
+                {
+                    t = Type.GetType(alias);
+
+                    if (t == null)
+                    {
+                        t = Type.GetType(alias + "." + service);
+                    }
+                }
+
                 // custom plugin could be defined in own namespace and assembly
                 if (t == null)
                 {
@@ -85,7 +97,6 @@ namespace WPCordovaClassLib.Cordova
                             break;
                         }
                     }
-
                 }
 
                 // unknown command, still didn't find it

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/af804749/wp8/template/cordovalib/NativeExecution.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/NativeExecution.cs b/wp8/template/cordovalib/NativeExecution.cs
index c8ec1bd..e8bda8f 100644
--- a/wp8/template/cordovalib/NativeExecution.cs
+++ b/wp8/template/cordovalib/NativeExecution.cs
@@ -85,7 +85,7 @@ namespace WPCordovaClassLib.Cordova
 
             try
             {
-                BaseCommand bc = CommandFactory.CreateByServiceName(commandCallParams.Service);
+                BaseCommand bc = CommandFactory.CreateByServiceName(commandCallParams.Service, commandCallParams.Namespace);
 
                 if (bc == null)
                 {
@@ -119,7 +119,7 @@ namespace WPCordovaClassLib.Cordova
                 {
                     try
                     {
-                        bc.InvokeMethodNamed(commandCallParams.CallbackId,commandCallParams.Action, commandCallParams.Args);
+                        bc.InvokeMethodNamed(commandCallParams.CallbackId, commandCallParams.Action, commandCallParams.Args);
                     }
                     catch (Exception ex)
                     {