示例#1
0
 public static JSProxyMgr GetInstance()
 {
     if (JSProxyMgr.s_Instance == null)
     {
         JSProxyMgr.s_Instance = new JSProxyMgr();
     }
     return(JSProxyMgr.s_Instance);
 }
示例#2
0
 public bool ProcessMessage(string jsonRequest, WebViewV8CallbackCSharp callback)
 {
     return(this.m_WebView != null && JSProxyMgr.GetInstance().DoMessage(jsonRequest, delegate(object result)
     {
         string result2 = JSProxyMgr.GetInstance().Stringify(result);
         callback.Callback(result2);
     }, this.m_WebView));
 }
示例#3
0
        public static void RunTestScript(string path)
        {
            var url = "file:///" + path;

            JSProxyMgr.GetInstance().AddGlobalObject("WebViewTestFunctions", new WebViewTestFunctions());
            var window = WebViewEditorWindowTabs.Create <WebViewEditorWindowTabs>("Test Window", url, 0, 0, 0, 0);

            window.OnBatchMode();
        }
        public static void RunTestScript(string path)
        {
            string sourcesPath = "file:///" + path;

            JSProxyMgr.GetInstance().AddGlobalObject("WebViewTestFunctions", new WebViewTestFunctions());
            WebViewEditorWindowTabs webViewEditorWindowTabs = WebViewEditorWindow.Create <WebViewEditorWindowTabs>("Test Window", sourcesPath, 0, 0, 0, 0);

            webViewEditorWindowTabs.OnBatchMode();
        }
 public override void Init()
 {
     if ((this.m_GlobalObject == null) && !string.IsNullOrEmpty(base.m_GlobalObjectTypeName))
     {
         System.Type type = System.Type.GetType(base.m_GlobalObjectTypeName);
         if (type != null)
         {
             this.m_GlobalObject = ScriptableObject.CreateInstance(type);
             JSProxyMgr.GetInstance().AddGlobalObject(this.m_GlobalObject.GetType().Name, this.m_GlobalObject);
         }
     }
 }
示例#6
0
 static JSProxyMgr()
 {
     JSProxyMgr.s_Instance       = null;
     JSProxyMgr.s_IgnoredMethods = new string[]
     {
         "Equals",
         "GetHashCode",
         "GetType",
         "ToString"
     };
     WebView.OnDomainReload();
 }
示例#7
0
 public override void Init()
 {
     if (m_GlobalObject == null && !string.IsNullOrEmpty(m_GlobalObjectTypeName))
     {
         var instanceType = Type.GetType(m_GlobalObjectTypeName);
         if (instanceType != null)
         {
             m_GlobalObject = ScriptableObject.CreateInstance(instanceType);
             JSProxyMgr.GetInstance().AddGlobalObject(m_GlobalObject.GetType().Name, m_GlobalObject);
         }
     }
 }
示例#8
0
 public void Init()
 {
     if ((this.m_GlobalObject == null) && !string.IsNullOrEmpty(this.m_GlobalObjectTypeName))
     {
         System.Type type = System.Type.GetType(this.m_GlobalObjectTypeName);
         if (type != null)
         {
             this.m_GlobalObject = Activator.CreateInstance(type);
             JSProxyMgr.GetInstance().AddGlobalObject(this.m_GlobalObject.GetType().Name, this.m_GlobalObject);
         }
     }
 }
 public bool ProcessMessage(string jsonRequest, WebViewV8CallbackCSharp callback)
 {
     if (m_WebView != null)
     {
         return(JSProxyMgr.GetInstance().DoMessage(jsonRequest, (object result) =>
         {
             string res = JSProxyMgr.GetInstance().Stringify(result);
             callback.Callback(res);
         }, m_WebView
                                                   ));
     }
     return(false);
 }
示例#10
0
 public bool ProcessMessage(string jsonRequest, WebViewV8CallbackCSharp callback)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     WebScriptObject.\u003CProcessMessage\u003Ec__AnonStoreyA3 messageCAnonStoreyA3 = new WebScriptObject.\u003CProcessMessage\u003Ec__AnonStoreyA3();
     // ISSUE: reference to a compiler-generated field
     messageCAnonStoreyA3.callback = callback;
     if ((Object)this.m_WebView != (Object)null)
     {
         // ISSUE: reference to a compiler-generated method
         return(JSProxyMgr.GetInstance().DoMessage(jsonRequest, new JSProxyMgr.ExecCallback(messageCAnonStoreyA3.\u003C\u003Em__1D4), this.m_WebView));
     }
     return(false);
 }
示例#11
0
        public bool DoMessage(string jsonRequest, JSProxyMgr.ExecCallback callback, WebView webView)
        {
            long messageID = -1L;
            bool result;

            try
            {
                Dictionary <string, object> dictionary = Json.Deserialize(jsonRequest) as Dictionary <string, object>;
                if (dictionary == null || !dictionary.ContainsKey("messageID") || !dictionary.ContainsKey("version") || !dictionary.ContainsKey("type"))
                {
                    callback(JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", jsonRequest));
                    result = false;
                    return(result);
                }
                messageID = (long)dictionary["messageID"];
                double num = double.Parse((string)dictionary["version"], CultureInfo.InvariantCulture);
                string a   = (string)dictionary["type"];
                if (num > 1.0)
                {
                    callback(JSProxyMgr.FormatError(messageID, -1004, "errUnsupportedProtocol", "The protocol version <" + num + "> is not supported by this verison of the code"));
                    result = false;
                    return(result);
                }
                if (a == "INVOKE")
                {
                    result = this.DoInvokeMessage(messageID, callback, dictionary);
                    return(result);
                }
                if (a == "GETSTUBINFO")
                {
                    result = this.DoGetStubInfoMessage(messageID, callback, dictionary);
                    return(result);
                }
                if (a == "ONEVENT")
                {
                    result = this.DoOnEventMessage(messageID, callback, dictionary, webView);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                callback(JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", ex.Message));
            }
            result = false;
            return(result);
        }
示例#12
0
        public bool DoMessage(string jsonRequest, JSProxyMgr.ExecCallback callback, WebView webView)
        {
            long messageID = -1;

            try
            {
                Dictionary <string, object> jsonData = Json.Deserialize(jsonRequest) as Dictionary <string, object>;
                if (jsonData == null || !jsonData.ContainsKey("messageID") || (!jsonData.ContainsKey("version") || !jsonData.ContainsKey("type")))
                {
                    callback((object)JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", jsonRequest));
                    return(false);
                }
                messageID = (long)jsonData["messageID"];
                double num = double.Parse((string)jsonData["version"]);
                string str = (string)jsonData["type"];
                if (num > 1.0)
                {
                    callback((object)JSProxyMgr.FormatError(messageID, -1004, "errUnsupportedProtocol", "The protocol version <" + (object)num + "> is not supported by this verison of the code"));
                    return(false);
                }
                if (str == "INVOKE")
                {
                    return(this.DoInvokeMessage(messageID, callback, jsonData));
                }
                if (str == "GETSTUBINFO")
                {
                    return(this.DoGetStubInfoMessage(messageID, callback, jsonData));
                }
                if (str == "ONEVENT")
                {
                    return(this.DoOnEventMessage(messageID, callback, jsonData, webView));
                }
            }
            catch (Exception ex)
            {
                callback((object)JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", ex.Message));
            }
            return(false);
        }
示例#13
0
 private void AddTask(JSProxyMgr.TaskCallback task)
 {
   if (this.m_TaskList == null)
     this.m_TaskList = new Queue<JSProxyMgr.TaskCallback>();
   this.m_TaskList.Enqueue(task);
 }
 static TroubleshooterAccess()
 {
     JSProxyMgr.GetInstance().AddGlobalObject("/unity/editor/troubleshooter", new TroubleshooterAccess());
 }
示例#15
0
 static ClipboardAccess()
 {
     JSProxyMgr.GetInstance().AddGlobalObject("unity/ClipboardAccess", new ClipboardAccess());
 }
示例#16
0
 public static void DoTasks()
 {
     JSProxyMgr.GetInstance().ProcessTasks();
 }
示例#17
0
        private bool DoGetStubInfoMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary <string, object> jsonData)
        {
            if (!jsonData.ContainsKey("reference"))
            {
                callback((object)JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "object reference missing"));
                return(false);
            }
            string reference         = (string)jsonData["reference"];
            object destinationObject = this.GetDestinationObject(reference);

            if (destinationObject == null)
            {
                callback((object)JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "cannot find object with reference <" + reference + ">"));
                return(false);
            }
            List <MethodInfo> list1 = ((IEnumerable <MethodInfo>)destinationObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)).ToList <MethodInfo>();

            list1.AddRange((IEnumerable <MethodInfo>)((IEnumerable <MethodInfo>)destinationObject.GetType().GetMethods(BindingFlags.Static | BindingFlags.Public)).ToList <MethodInfo>());
            ArrayList arrayList1 = new ArrayList();

            using (List <MethodInfo> .Enumerator enumerator = list1.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    MethodInfo current = enumerator.Current;
                    if (Array.IndexOf <string>(JSProxyMgr.s_IgnoredMethods, current.Name) < 0 && (!current.IsSpecialName || !current.Name.StartsWith("set_") && !current.Name.StartsWith("get_")))
                    {
                        System.Reflection.ParameterInfo[] parameters = current.GetParameters();
                        ArrayList arrayList2 = new ArrayList();
                        foreach (System.Reflection.ParameterInfo parameterInfo in parameters)
                        {
                            arrayList2.Add((object)parameterInfo.Name);
                        }
                        JspmMethodInfo jspmMethodInfo = new JspmMethodInfo(current.Name, (string[])arrayList2.ToArray(typeof(string)));
                        arrayList1.Add((object)jspmMethodInfo);
                    }
                }
            }
            List <PropertyInfo> list2      = ((IEnumerable <PropertyInfo>)destinationObject.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)).ToList <PropertyInfo>();
            ArrayList           arrayList3 = new ArrayList();

            using (List <PropertyInfo> .Enumerator enumerator = list2.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PropertyInfo current = enumerator.Current;
                    arrayList3.Add((object)new JspmPropertyInfo(current.Name, current.GetValue(destinationObject, (object[])null)));
                }
            }
            using (List <System.Reflection.FieldInfo> .Enumerator enumerator = ((IEnumerable <System.Reflection.FieldInfo>)destinationObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)).ToList <System.Reflection.FieldInfo>().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    System.Reflection.FieldInfo current = enumerator.Current;
                    arrayList3.Add((object)new JspmPropertyInfo(current.Name, current.GetValue(destinationObject)));
                }
            }
            List <EventInfo> list3      = ((IEnumerable <EventInfo>)destinationObject.GetType().GetEvents(BindingFlags.Instance | BindingFlags.Public)).ToList <EventInfo>();
            ArrayList        arrayList4 = new ArrayList();

            using (List <EventInfo> .Enumerator enumerator = list3.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    EventInfo current = enumerator.Current;
                    arrayList4.Add((object)current.Name);
                }
            }
            callback((object)new JspmStubInfoSuccess(messageID, reference, (JspmPropertyInfo[])arrayList3.ToArray(typeof(JspmPropertyInfo)), (JspmMethodInfo[])arrayList1.ToArray(typeof(JspmMethodInfo)), (string[])arrayList4.ToArray(typeof(string))));
            return(true);
        }
示例#18
0
        private bool DoInvokeMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary <string, object> jsonData)
        {
            bool result;

            if (!jsonData.ContainsKey("destination") || !jsonData.ContainsKey("method") || !jsonData.ContainsKey("params"))
            {
                callback(JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "object reference, method name or parameters missing"));
                result = false;
            }
            else
            {
                string        text       = (string)jsonData["destination"];
                string        text2      = (string)jsonData["method"];
                List <object> data       = (List <object>)jsonData["params"];
                object        destObject = this.GetDestinationObject(text);
                if (destObject == null)
                {
                    callback(JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "cannot find object with reference <" + text + ">"));
                    result = false;
                }
                else
                {
                    Type         type        = destObject.GetType();
                    MethodInfo[] methods     = type.GetMethods();
                    MethodInfo   foundMethod = null;
                    object[]     parameters  = null;
                    string       text3       = "";
                    MethodInfo[] array       = methods;
                    for (int i = 0; i < array.Length; i++)
                    {
                        MethodInfo methodInfo = array[i];
                        if (!(methodInfo.Name != text2))
                        {
                            try
                            {
                                parameters  = this.ParseParams(methodInfo, data);
                                foundMethod = methodInfo;
                                break;
                            }
                            catch (Exception ex)
                            {
                                text3 = ex.Message;
                            }
                        }
                    }
                    if (foundMethod == null)
                    {
                        callback(JSProxyMgr.FormatError(messageID, -1002, "errUnknownMethod", string.Concat(new string[]
                        {
                            "cannot find method <",
                            text2,
                            "> for object <",
                            text,
                            ">, reason:",
                            text3
                        })));
                        result = false;
                    }
                    else
                    {
                        this.AddTask(delegate
                        {
                            try
                            {
                                object result2 = foundMethod.Invoke(destObject, parameters);
                                callback(JSProxyMgr.FormatSuccess(messageID, result2));
                            }
                            catch (TargetInvocationException ex2)
                            {
                                if (ex2.InnerException != null)
                                {
                                    callback(JSProxyMgr.FormatError(messageID, -1003, ex2.InnerException.GetType().Name, ex2.InnerException.Message));
                                }
                                else
                                {
                                    callback(JSProxyMgr.FormatError(messageID, -1003, ex2.GetType().Name, ex2.Message));
                                }
                            }
                            catch (Exception ex3)
                            {
                                callback(JSProxyMgr.FormatError(messageID, -1003, ex3.GetType().Name, ex3.Message));
                            }
                        });
                        result = true;
                    }
                }
            }
            return(result);
        }
示例#19
0
 private bool DoOnEventMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary <string, object> jsonData, WebView webView)
 {
     callback(JSProxyMgr.FormatError(messageID, -1002, "errUnknownMethod", "method DoOnEventMessage is deprecated"));
     return(false);
 }
示例#20
0
        private bool DoGetStubInfoMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary <string, object> jsonData)
        {
            bool result;

            if (!jsonData.ContainsKey("reference"))
            {
                callback(JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "object reference missing"));
                result = false;
            }
            else
            {
                string text = (string)jsonData["reference"];
                object destinationObject = this.GetDestinationObject(text);
                if (destinationObject == null)
                {
                    callback(JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "cannot find object with reference <" + text + ">"));
                    result = false;
                }
                else
                {
                    List <MethodInfo> list = destinationObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public).ToList <MethodInfo>();
                    list.AddRange(destinationObject.GetType().GetMethods(BindingFlags.Static | BindingFlags.Public).ToList <MethodInfo>());
                    ArrayList arrayList = new ArrayList();
                    foreach (MethodInfo current in list)
                    {
                        if (Array.IndexOf <string>(JSProxyMgr.s_IgnoredMethods, current.Name) < 0)
                        {
                            if (!current.IsSpecialName || (!current.Name.StartsWith("set_") && !current.Name.StartsWith("get_")))
                            {
                                ParameterInfo[] parameters = current.GetParameters();
                                ArrayList       arrayList2 = new ArrayList();
                                ParameterInfo[] array      = parameters;
                                for (int i = 0; i < array.Length; i++)
                                {
                                    ParameterInfo parameterInfo = array[i];
                                    arrayList2.Add(parameterInfo.Name);
                                }
                                JspmMethodInfo value = new JspmMethodInfo(current.Name, (string[])arrayList2.ToArray(typeof(string)));
                                arrayList.Add(value);
                            }
                        }
                    }
                    List <PropertyInfo> list2      = destinationObject.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public).ToList <PropertyInfo>();
                    ArrayList           arrayList3 = new ArrayList();
                    foreach (PropertyInfo current2 in list2)
                    {
                        arrayList3.Add(new JspmPropertyInfo(current2.Name, current2.GetValue(destinationObject, null)));
                    }
                    List <FieldInfo> list3 = destinationObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).ToList <FieldInfo>();
                    foreach (FieldInfo current3 in list3)
                    {
                        arrayList3.Add(new JspmPropertyInfo(current3.Name, current3.GetValue(destinationObject)));
                    }
                    List <EventInfo> list4      = destinationObject.GetType().GetEvents(BindingFlags.Instance | BindingFlags.Public).ToList <EventInfo>();
                    ArrayList        arrayList4 = new ArrayList();
                    foreach (EventInfo current4 in list4)
                    {
                        arrayList4.Add(current4.Name);
                    }
                    callback(new JspmStubInfoSuccess(messageID, text, (JspmPropertyInfo[])arrayList3.ToArray(typeof(JspmPropertyInfo)), (JspmMethodInfo[])arrayList.ToArray(typeof(JspmMethodInfo)), (string[])arrayList4.ToArray(typeof(string))));
                    result = true;
                }
            }
            return(result);
        }
示例#21
0
        private bool DoInvokeMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary <string, object> jsonData)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            JSProxyMgr.\u003CDoInvokeMessage\u003Ec__AnonStoreyA2 messageCAnonStoreyA2 = new JSProxyMgr.\u003CDoInvokeMessage\u003Ec__AnonStoreyA2();
            // ISSUE: reference to a compiler-generated field
            messageCAnonStoreyA2.callback = callback;
            // ISSUE: reference to a compiler-generated field
            messageCAnonStoreyA2.messageID = messageID;
            if (!jsonData.ContainsKey("destination") || !jsonData.ContainsKey("method") || !jsonData.ContainsKey("params"))
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                messageCAnonStoreyA2.callback((object)JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1001, "errUnknownObject", "object reference, method name or parameters missing"));
                return(false);
            }
            string        reference = (string)jsonData["destination"];
            string        str1      = (string)jsonData["method"];
            List <object> data      = (List <object>)jsonData["params"];

            // ISSUE: reference to a compiler-generated field
            messageCAnonStoreyA2.destObject = this.GetDestinationObject(reference);
            // ISSUE: reference to a compiler-generated field
            if (messageCAnonStoreyA2.destObject == null)
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                messageCAnonStoreyA2.callback((object)JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1001, "errUnknownObject", "cannot find object with reference <" + reference + ">"));
                return(false);
            }
            // ISSUE: reference to a compiler-generated field
            MethodInfo[] methods = messageCAnonStoreyA2.destObject.GetType().GetMethods();
            // ISSUE: reference to a compiler-generated field
            messageCAnonStoreyA2.foundMethod = (MethodInfo)null;
            // ISSUE: reference to a compiler-generated field
            messageCAnonStoreyA2.parameters = (object[])null;
            string str2 = string.Empty;

            foreach (MethodInfo method in methods)
            {
                if (!(method.Name != str1))
                {
                    try
                    {
                        // ISSUE: reference to a compiler-generated field
                        messageCAnonStoreyA2.parameters = this.ParseParams(method, data);
                        // ISSUE: reference to a compiler-generated field
                        messageCAnonStoreyA2.foundMethod = method;
                        break;
                    }
                    catch (Exception ex)
                    {
                        str2 = ex.Message;
                    }
                }
            }
            // ISSUE: reference to a compiler-generated field
            if (messageCAnonStoreyA2.foundMethod == null)
            {
                // ISSUE: reference to a compiler-generated field
                // ISSUE: reference to a compiler-generated field
                messageCAnonStoreyA2.callback((object)JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1002, "errUnknownMethod", "cannot find method <" + str1 + "> for object <" + reference + ">, reason:" + str2));
                return(false);
            }
            // ISSUE: reference to a compiler-generated method
            this.AddTask(new JSProxyMgr.TaskCallback(messageCAnonStoreyA2.\u003C\u003Em__1D3));
            return(true);
        }
示例#22
0
 private bool DoGetStubInfoMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary<string, object> jsonData)
 {
   if (!jsonData.ContainsKey("reference"))
   {
     callback((object) JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "object reference missing"));
     return false;
   }
   string reference = (string) jsonData["reference"];
   object destinationObject = this.GetDestinationObject(reference);
   if (destinationObject == null)
   {
     callback((object) JSProxyMgr.FormatError(messageID, -1001, "errUnknownObject", "cannot find object with reference <" + reference + ">"));
     return false;
   }
   List<MethodInfo> list1 = ((IEnumerable<MethodInfo>) destinationObject.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)).ToList<MethodInfo>();
   list1.AddRange((IEnumerable<MethodInfo>) ((IEnumerable<MethodInfo>) destinationObject.GetType().GetMethods(BindingFlags.Static | BindingFlags.Public)).ToList<MethodInfo>());
   ArrayList arrayList1 = new ArrayList();
   using (List<MethodInfo>.Enumerator enumerator = list1.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       MethodInfo current = enumerator.Current;
       if (Array.IndexOf<string>(JSProxyMgr.s_IgnoredMethods, current.Name) < 0 && (!current.IsSpecialName || !current.Name.StartsWith("set_") && !current.Name.StartsWith("get_")))
       {
         System.Reflection.ParameterInfo[] parameters = current.GetParameters();
         ArrayList arrayList2 = new ArrayList();
         foreach (System.Reflection.ParameterInfo parameterInfo in parameters)
           arrayList2.Add((object) parameterInfo.Name);
         JspmMethodInfo jspmMethodInfo = new JspmMethodInfo(current.Name, (string[]) arrayList2.ToArray(typeof (string)));
         arrayList1.Add((object) jspmMethodInfo);
       }
     }
   }
   List<PropertyInfo> list2 = ((IEnumerable<PropertyInfo>) destinationObject.GetType().GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)).ToList<PropertyInfo>();
   ArrayList arrayList3 = new ArrayList();
   using (List<PropertyInfo>.Enumerator enumerator = list2.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       PropertyInfo current = enumerator.Current;
       arrayList3.Add((object) new JspmPropertyInfo(current.Name, current.GetValue(destinationObject, (object[]) null)));
     }
   }
   using (List<System.Reflection.FieldInfo>.Enumerator enumerator = ((IEnumerable<System.Reflection.FieldInfo>) destinationObject.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)).ToList<System.Reflection.FieldInfo>().GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       System.Reflection.FieldInfo current = enumerator.Current;
       arrayList3.Add((object) new JspmPropertyInfo(current.Name, current.GetValue(destinationObject)));
     }
   }
   List<EventInfo> list3 = ((IEnumerable<EventInfo>) destinationObject.GetType().GetEvents(BindingFlags.Instance | BindingFlags.Public)).ToList<EventInfo>();
   ArrayList arrayList4 = new ArrayList();
   using (List<EventInfo>.Enumerator enumerator = list3.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       EventInfo current = enumerator.Current;
       arrayList4.Add((object) current.Name);
     }
   }
   callback((object) new JspmStubInfoSuccess(messageID, reference, (JspmPropertyInfo[]) arrayList3.ToArray(typeof (JspmPropertyInfo)), (JspmMethodInfo[]) arrayList1.ToArray(typeof (JspmMethodInfo)), (string[]) arrayList4.ToArray(typeof (string))));
   return true;
 }
示例#23
0
 private bool DoOnEventMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary<string, object> jsonData, WebView webView)
 {
   callback((object) JSProxyMgr.FormatError(messageID, -1002, "errUnknownMethod", "method DoOnEventMessage is depracated"));
   return false;
 }
示例#24
0
 public static JSProxyMgr GetInstance()
 {
   if (JSProxyMgr.s_Instance == null)
     JSProxyMgr.s_Instance = new JSProxyMgr();
   return JSProxyMgr.s_Instance;
 }
示例#25
0
 private bool DoInvokeMessage(long messageID, JSProxyMgr.ExecCallback callback, Dictionary<string, object> jsonData)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   JSProxyMgr.\u003CDoInvokeMessage\u003Ec__AnonStoreyA2 messageCAnonStoreyA2 = new JSProxyMgr.\u003CDoInvokeMessage\u003Ec__AnonStoreyA2();
   // ISSUE: reference to a compiler-generated field
   messageCAnonStoreyA2.callback = callback;
   // ISSUE: reference to a compiler-generated field
   messageCAnonStoreyA2.messageID = messageID;
   if (!jsonData.ContainsKey("destination") || !jsonData.ContainsKey("method") || !jsonData.ContainsKey("params"))
   {
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     messageCAnonStoreyA2.callback((object) JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1001, "errUnknownObject", "object reference, method name or parameters missing"));
     return false;
   }
   string reference = (string) jsonData["destination"];
   string str1 = (string) jsonData["method"];
   List<object> data = (List<object>) jsonData["params"];
   // ISSUE: reference to a compiler-generated field
   messageCAnonStoreyA2.destObject = this.GetDestinationObject(reference);
   // ISSUE: reference to a compiler-generated field
   if (messageCAnonStoreyA2.destObject == null)
   {
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     messageCAnonStoreyA2.callback((object) JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1001, "errUnknownObject", "cannot find object with reference <" + reference + ">"));
     return false;
   }
   // ISSUE: reference to a compiler-generated field
   MethodInfo[] methods = messageCAnonStoreyA2.destObject.GetType().GetMethods();
   // ISSUE: reference to a compiler-generated field
   messageCAnonStoreyA2.foundMethod = (MethodInfo) null;
   // ISSUE: reference to a compiler-generated field
   messageCAnonStoreyA2.parameters = (object[]) null;
   string str2 = string.Empty;
   foreach (MethodInfo method in methods)
   {
     if (!(method.Name != str1))
     {
       try
       {
         // ISSUE: reference to a compiler-generated field
         messageCAnonStoreyA2.parameters = this.ParseParams(method, data);
         // ISSUE: reference to a compiler-generated field
         messageCAnonStoreyA2.foundMethod = method;
         break;
       }
       catch (Exception ex)
       {
         str2 = ex.Message;
       }
     }
   }
   // ISSUE: reference to a compiler-generated field
   if (messageCAnonStoreyA2.foundMethod == null)
   {
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     messageCAnonStoreyA2.callback((object) JSProxyMgr.FormatError(messageCAnonStoreyA2.messageID, -1002, "errUnknownMethod", "cannot find method <" + str1 + "> for object <" + reference + ">, reason:" + str2));
     return false;
   }
   // ISSUE: reference to a compiler-generated method
   this.AddTask(new JSProxyMgr.TaskCallback(messageCAnonStoreyA2.\u003C\u003Em__1D3));
   return true;
 }
示例#26
0
 static EditorProjectAccess()
 {
     JSProxyMgr.GetInstance().AddGlobalObject("unity/project", new EditorProjectAccess());
 }
示例#27
0
 public bool DoMessage(string jsonRequest, JSProxyMgr.ExecCallback callback, WebView webView)
 {
   long messageID = -1;
   try
   {
     Dictionary<string, object> jsonData = Json.Deserialize(jsonRequest) as Dictionary<string, object>;
     if (jsonData == null || !jsonData.ContainsKey("messageID") || (!jsonData.ContainsKey("version") || !jsonData.ContainsKey("type")))
     {
       callback((object) JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", jsonRequest));
       return false;
     }
     messageID = (long) jsonData["messageID"];
     double num = double.Parse((string) jsonData["version"]);
     string str = (string) jsonData["type"];
     if (num > 1.0)
     {
       callback((object) JSProxyMgr.FormatError(messageID, -1004, "errUnsupportedProtocol", "The protocol version <" + (object) num + "> is not supported by this verison of the code"));
       return false;
     }
     if (str == "INVOKE")
       return this.DoInvokeMessage(messageID, callback, jsonData);
     if (str == "GETSTUBINFO")
       return this.DoGetStubInfoMessage(messageID, callback, jsonData);
     if (str == "ONEVENT")
       return this.DoOnEventMessage(messageID, callback, jsonData, webView);
   }
   catch (Exception ex)
   {
     callback((object) JSProxyMgr.FormatError(messageID, -1000, "errInvalidMessageFormat", ex.Message));
   }
   return false;
 }