public void init(string options)
        {
            string callbackId;
            options = options.Replace("{}", ""); /// empty objects screw up the Deserializer
            try
            {
                /// name, type
                string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
                /// to test maybe is not a string but a JSONObject
                EntryInit entryInit = JSON.JsonHelper.Deserialize<EntryInit>(args[0]);
                string type = entryInit.type;
                string typepath = entryInit.typepath;
                string url = entryInit.url;
                callbackId = args[1];

                if (type != null && type.Equals(ACTION_OPEN_TYPE_DB))
                {
                    //string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, name);
                    mbTilesActions = new MBTilesActionsDatabaseImpl(typepath, url);
                }
                else if (type != null && type.Equals(ACTION_OPEN_TYPE_FILE))
                {
                    //string dirPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "maps//" + name);
                    mbTilesActions = new MBTilesActionsFileImpl(typepath, url);
                }
               

                if (mbTilesActions != null)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), callbackId);
                }

            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
            }

        }
Beispiel #2
0
        public void init(string options)
        {
            string callbackId;

            options = options.Replace("{}", ""); /// empty objects screw up the Deserializer
            try
            {
                /// name, type
                string[] args = JSON.JsonHelper.Deserialize <string[]>(options);
                /// to test maybe is not a string but a JSONObject
                EntryInit entryInit = JSON.JsonHelper.Deserialize <EntryInit>(args[0]);
                string    type      = entryInit.type;
                string    typepath  = entryInit.typepath;
                string    url       = entryInit.url;
                callbackId = args[1];

                if (type != null && type.Equals(ACTION_OPEN_TYPE_DB))
                {
                    //string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, name);
                    mbTilesActions = new MBTilesActionsDatabaseImpl(typepath, url);
                }
                else if (type != null && type.Equals(ACTION_OPEN_TYPE_FILE))
                {
                    //string dirPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "maps//" + name);
                    mbTilesActions = new MBTilesActionsFileImpl(typepath, url);
                }


                if (mbTilesActions != null)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId);
                }
                else
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION), callbackId);
                }
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
            }
        }