Exemplo n.º 1
0
        public static JsReturn Return(object o)
        {
            JsReturn ret = new JsReturn();

            ret.Value = o;
            return(ret);
        }
Exemplo n.º 2
0
        public override void StartLoading()
        {
            try
            {
                string objName = Request.Url.Host;
                string dataraw = Request.Url.Query.Split('=')[1];
                string json    = System.Web.HttpUtility.UrlDecode(dataraw).Replace("&_", "");

                JsReturn result = JSBridge.RaiseEvent(JsTelegram.DeserializeObject(json));

                // indicate success.
                var data = NSData.FromString(result.Serialize());
                Console.WriteLine(data);
                using (var response = new NSUrlResponse(Request.Url, "application/json", Convert.ToInt32(data.Length), "utf-8"))
                {
                    Client.ReceivedResponse(this, response, NSUrlCacheStoragePolicy.NotAllowed);
                    Client.DataLoaded(this, data);
                    Client.FinishedLoading(this);
                }
            }
            catch (Exception)
            {
                Client.FailedWithError(this, NSError.FromDomain(new NSString("AppProtocolHandler"), Convert.ToInt32(NSUrlError.ResourceUnavailable)));
                Client.FinishedLoading(this);
            }
        }
Exemplo n.º 3
0
        public static JsReturn RaiseEvent(JsTelegram telegram)
        {
            object     ret  = null;
            string     name = telegram.ObjName;
            object     obj  = m_objects[name];
            Type       t    = obj.GetType();
            ObjectInfo info = m_info_objects[name];

            try
            {
                System.Reflection.MethodInfo method = t.GetMethod(telegram.MethodName);
                ret = method.Invoke(obj, telegram.Parameters.ToArray());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            return(JsReturn.Return(ret));
        }