Esempio n. 1
0
        public virtual CallResult ReinitializeServerUid(CallConfig config)
        {
            CallResult result = null;
            string     newUid = Guid.NewGuid().ToString();

            MicroServer.Instance.ReinitializeInstanceUid(newUid);

            ///-------------------------------------------------
            ///now we have to let know frontend of the change of
            ///server instance UID that happened
            ///-------------------------------------------------
            //CallFrontend(string.Format("setServerInstanceUid('{0}');",newUid); //alternative 1

            ///'native' way via CallResult - alternative 2
            string frontendCallbackConfig = CallConfig.NewCallConfig("setServerInstanceUid", newUid).ToJsonString();

            result = new CallResult(frontendCallbackConfig);
            return(result);
        }
Esempio n. 2
0
 public CallResult ProcessCallFromFrontend(CallConfig config)
 {
     return(implementer.ProcessCallFromFrontend(config));
 }
        public virtual CallResult ProcessCallFromFrontend(CallConfig config)               //dict["name"]
        {
            DLogger.WriteLog("Call from frontend of method name:{0} with arguments:{1}", config.MethodName, config.Params);

            object     instance  = webView.Page;
            MethodInfo theMethod = null;

            if (Page != null)  //first lets look for the method in the page
            {
                theMethod = Page.GetType().GetMethod(config.MethodName);
            }

            if (theMethod == null)
            {
                theMethod = webView.GetType().GetMethod(config.MethodName);
                instance  = webView;
            }

            if (theMethod == null)  //if the method is not found in current view, then lets search for it in other loaded views
            {
                foreach (var view in LoadedViews.ViewForEachType)
                {
                    theMethod = view.GetType().GetMethod(config.MethodName);
                    if (theMethod != null)
                    {
                        instance = view;
                        break;
                    }
                }
            }

            if (theMethod == null)  //if the method is not found in loaded views, then lets search for it in parent window
            {
                theMethod = ParentWindow.GetType().GetMethod(config.MethodName);
                instance  = ParentWindow;
            }

            if (theMethod == null)  //if the method is not found in parent window, then lets search for it in AppDelegate.Instance
            {
                theMethod = BaseAppDelegate.Instance.GetType().GetMethod(config.MethodName);
                instance  = BaseAppDelegate.Instance;
            }

            CallResult result = new CallResult(string.Empty);

            try {
                //BaseAppDelegate.Instance.InvokeOnMainThread(()=>{
                result = (CallResult)theMethod.Invoke(instance, new object[] { config.Params });
                //});
            } catch (Exception ex) {
                DLogger.WriteLog(ex);
                try {//try parameter less
                    //BaseAppDelegate.Instance.InvokeOnMainThread(()=>{
                    result = (CallResult)theMethod.Invoke(instance, null);
                    //});
                } catch (Exception ex2) {
                    DLogger.WriteLog(ex2);
                }
            }

            return(result);
        }
Esempio n. 4
0
        /// A place to start putting your methods, like we used to in WinForms in the old good days;)

        public CallResult Quit()
        {
            string textResult = new CallConfig(Guid.NewGuid(), "displayShowcaseInfo", "On Android you don't have to exit your app! Press \"Home\" button instead. ").ToJsonString();

            return(new CallResult(textResult));
        }
Esempio n. 5
0
 public virtual CallResult ProcessCallFromFrontend(CallConfig config)
 {
     return(TopWebView.ProcessCallFromFrontend(config));
 }