Пример #1
0
        private void LoadDataFromDLL()
        {
#if ILPROJ
            var path         = LC_RuntimeManager.DLL_PATH;
            var method_count = 0;

            foreach (var full_path in Directory.GetFiles(path, "*_dlc.txt", SearchOption.TopDirectoryOnly))
            {
                var module = ModuleDefinition.ReadModule(full_path);
                if (module == null)
                {
                    return;
                }

                foreach (var typeDefine in module.Types)
                {
                    method_count += typeDefine.Methods.Count;
                    foreach (var methodDefine in typeDefine.Methods)
                    {
                        var methodName   = methodDefine.FullName;
                        var instructions = methodDefine?.Body?.Instructions;
                        if (instructions == null)
                        {
                            continue;
                        }

                        foreach (var instruct in instructions)
                        {
                            var now_inst = instruct.Operand as MethodReference;
                            if (now_inst == null)
                            {
                                continue;
                            }
                            var now_all  = now_inst.ToString();
                            var now_name = now_inst.DeclaringType.FullName;
                            var now_ret  = now_inst.ReturnType.ToString();

                            if (instruct.OpCode == OpCodes.Call && !DelegateType.IsDelegateType(now_all))
                            {
                                if (IsExceptContent(now_name))
                                {
                                    continue;
                                }

                                //generic|para|return|
                                ParameterProcess(now_all, now_ret);
                            }

                            if (instruct.OpCode != OpCodes.Newobj || instruct.Previous == null || instruct.Previous.OpCode != OpCodes.Ldftn)
                            {
                                continue;
                            }
                            if (!DelegateType.IsDelegateType(now_all))
                            {
                                continue;
                            }
                            var pre_inst = instruct.Previous.Operand as MethodReference;
                            if (pre_inst == null)
                            {
                                continue;
                            }
                            var pre_all       = pre_inst.ToString();
                            var pre_ret       = pre_inst.ReturnType.ToString();
                            var register_name = now_name;
                            //string wait_name = now_name;
                            //string wait_ret = now_ret;

                            if (now_name.Contains(DelegateType.Delegate))
                            {
                                var para_regex = new Regex(" .*?::(.*)");
                                if (para_regex.IsMatch(pre_all))
                                {
                                    register_name = para_regex.Match(pre_all).Groups[0].Value;
                                    //wait_name = para_regex.Match(pre_all).Groups[0].Value;
                                    //wait_ret = pre_ret;
                                }
                            }

                            if (IsExceptContent(pre_all))
                            {
                                continue;
                            }

                            //method|generic|para|return|
                            var line_para = ParameterProcess(pre_all, pre_ret, now_name);
                            if (string.IsNullOrEmpty(line_para))
                            {
                                line_para = @"|||";
                            }
                            MethodProcess(register_name, line_para);
                        }
                    }
                }
            }

            AddCustomAdaptor();
            AddCustomConverter();

            //for (int i = 0; i < _delegateAdaptorList.Count; i++)
            //{
            //    Debug.Log(string.Format("******* Delegate Adpater Index:[{0}] Content:[{1}] *******", i, _delegateAdaptorList[i]));
            //}
            //Debug.Log(" =========================== Delegate Adpater Up && Convert Down 4 =========================== ");
            //for (int i = 0; i < _delegateConvertList.Count; i++)
            //{
            //    Debug.Log(string.Format("******* Delegate Converter Index:[{0}] Content:[{1}] *******", i, _delegateConvertList[i]));
            //}
            for (var i = 0; i < _overParaList.Count; i++)
            {
                Debug.LogWarning(string.Format("!!!!! Parameters Over !!!!! index:[{0}] Content:[{1}]", i, _overParaList[i]));
            }
#endif
        }