private string CreateDelegateRegisterInit(object type)
        {
            string tmpd = null;

            if (type is Type)
            {
                var t      = (Type)type;
                var method = t.GetMethod("Invoke");
                if (method == null)
                {
                    return("");
                }
                tmpd = method.ReturnType == typeof(void) ? "action_register.tmpd" : "function_register.tmpd";
            }
            else if (type is TypeReference)
            {
                var tr = (TypeReference)type;
                if (tr.FullName.Contains("Action") || tr.FullName.Contains("Func"))
                {//如果委托类型是Action或者Func,直接判定采用那个模板
                    tmpd = tr.FullName.Contains("Action") ? "action_register.tmpd" : "function_register.tmpd";
                }
                else
                {
                    var td = tr.Resolve();
                    if (td != null)
                    {
                        foreach (var method in td.Methods)
                        {
                            if (method.FullName.Contains("Invoke") && !method.FullName.Contains("BeginInvoke") && !method.FullName.Contains("EndInvoke"))
                            {//如果是Invoke方法,获取其参数
                                tmpd = method.ReturnType.FullName.Equals("System.Void") ? "action_register.tmpd" : "function_register.tmpd";
                                break;
                            }
                        }
                    }
                }
            }
            _drg.InitFromFile(_filePath + Path.AltDirectorySeparatorChar + tmpd, type);

            return(_drg.Generate());
        }
Example #2
0
        private string CreateDelegateRegisterInit(object type)
        {
            string tmpd = null;

            if (type is Type)
            {
                var t      = (Type)type;
                var method = t.GetMethod("Invoke");
                if (method == null)
                {
                    return("");
                }
                tmpd = method.ReturnType == typeof(void) ? "action_register.tmpd" : "function_register.tmpd";
            }
            else if (type is TypeReference)
            {
                var tr = (TypeReference)type;
                tmpd = tr.FullName.Contains("Action") ? "action_register.tmpd" : "function_register.tmpd";
            }
            _drg.InitFromFile(_filePath + Path.AltDirectorySeparatorChar + tmpd, type);

            return(_drg.Generate());
        }