Esempio n. 1
0
            public void Init(IntPtr hLib, string jsonStr)
            {
                CurrentDomain.DoCallBack(() =>
                {
                    JObject json = JObject.Parse(jsonStr);
                    Initialize   = (Type_Initialize)Invoke(hLib, "Initialize", typeof(Type_Initialize));
                    AppInfo      = (Type_AppInfo)Invoke(hLib, "AppInfo", typeof(Type_AppInfo));
                    foreach (var item in JArray.Parse(json["event"].ToString()))
                    {
                        switch (item["id"].ToString())
                        {
                        case "1":
                            PrivateMsg = (Type_PrivateMsg)Invoke(hLib, item["function"].ToString(), typeof(Type_PrivateMsg));
                            break;

                        case "2":
                            GroupMsg = (Type_GroupMsg)Invoke(hLib, item["function"].ToString(), typeof(Type_GroupMsg));
                            break;

                        case "4":
                            Upload = (Type_Upload)Invoke(hLib, item["function"].ToString(), typeof(Type_Upload));
                            break;

                        case "5":
                            AdminChange = (Type_AdminChange)Invoke(hLib, item["function"].ToString(), typeof(Type_AdminChange));
                            break;

                        case "6":
                            GroupMemberDecrease = (Type_GroupMemberDecrease)Invoke(hLib, item["function"].ToString(), typeof(Type_GroupMemberDecrease));
                            break;

                        case "7":
                            GroupMemberIncrease = (Type_GroupMemberIncrease)Invoke(hLib, item["function"].ToString(), typeof(Type_GroupMemberIncrease));
                            break;

                        case "8":
                            GroupBan = (Type_GroupBan)Invoke(hLib, item["function"].ToString(), typeof(Type_GroupBan));
                            break;

                        case "10":
                            FriendAdded = (Type_FriendAdded)Invoke(hLib, item["function"].ToString(), typeof(Type_FriendAdded));
                            break;

                        case "11":
                            FriendRequest = (Type_FriendRequest)Invoke(hLib, item["function"].ToString(), typeof(Type_FriendRequest));
                            break;

                        case "12":
                            GroupAddRequest = (Type_GroupAddRequest)Invoke(hLib, item["function"].ToString(), typeof(Type_GroupAddRequest));
                            break;

                        case "1001":
                            Startup = (Type_Startup)Invoke(hLib, item["function"].ToString(), typeof(Type_Startup));
                            break;

                        case "1002":
                            Exit = (Type_Exit)Invoke(hLib, item["function"].ToString(), typeof(Type_Exit));
                            break;

                        case "1003":
                            Enable = (Type_Enable)Invoke(hLib, item["function"].ToString(), typeof(Type_Enable));
                            break;

                        case "1004":
                            Disable = (Type_Disable)Invoke(hLib, item["function"].ToString(), typeof(Type_Disable));
                            break;
                        }
                    }
                });
            }
Esempio n. 2
0
        public IntPtr Load(string filepath, JObject json)
        {
            if (hLib == null || hLib == (IntPtr)0)
            {
                try { hLib = LoadLibrary(filepath); }
                catch
                {
                    LogHelper.WriteLine("Error", $"插件 {filepath} 载入失败,LoadLibrary :GetLastError={GetLastError()}");
                }
            }
            if (hLib != (IntPtr)0)
            {
                Initialize = (Type_Initialize)Invoke("Initialize", typeof(Type_Initialize));
                AppInfo    = (Type_AppInfo)Invoke("AppInfo", typeof(Type_AppInfo));
                foreach (var item in JArray.Parse(json["event"].ToString()))
                {
                    switch (item["id"].ToString())
                    {
                    case "1":
                        PrivateMsg = (Type_PrivateMsg)Invoke(item["function"].ToString(), typeof(Type_PrivateMsg));
                        break;

                    case "2":
                        GroupMsg = (Type_GroupMsg)Invoke(item["function"].ToString(), typeof(Type_GroupMsg));
                        break;

                    case "4":
                        Upload = (Type_Upload)Invoke(item["function"].ToString(), typeof(Type_Upload));
                        break;

                    case "5":
                        AdminChange = (Type_AdminChange)Invoke(item["function"].ToString(), typeof(Type_AdminChange));
                        break;

                    case "6":
                        GroupMemberDecrease = (Type_GroupMemberDecrease)Invoke(item["function"].ToString(), typeof(Type_GroupMemberDecrease));
                        break;

                    case "7":
                        GroupMemberIncrease = (Type_GroupMemberIncrease)Invoke(item["function"].ToString(), typeof(Type_GroupMemberIncrease));
                        break;

                    case "8":
                        GroupBan = (Type_GroupBan)Invoke(item["function"].ToString(), typeof(Type_GroupBan));
                        break;

                    case "10":
                        FriendAdded = (Type_FriendAdded)Invoke(item["function"].ToString(), typeof(Type_FriendAdded));
                        break;

                    case "11":
                        FriendRequest = (Type_FriendRequest)Invoke(item["function"].ToString(), typeof(Type_FriendRequest));
                        break;

                    case "12":
                        GroupAddRequest = (Type_GroupAddRequest)Invoke(item["function"].ToString(), typeof(Type_GroupAddRequest));
                        break;

                    case "1001":
                        Startup = (Type_Startup)Invoke(item["function"].ToString(), typeof(Type_Startup));
                        break;

                    case "1002":
                        Exit = (Type_Exit)Invoke(item["function"].ToString(), typeof(Type_Exit));
                        break;

                    case "1003":
                        Enable = (Type_Enable)Invoke(item["function"].ToString(), typeof(Type_Enable));
                        break;

                    case "1004":
                        Disable = (Type_Disable)Invoke(item["function"].ToString(), typeof(Type_Disable));
                        break;
                    }
                }
                return(hLib);
            }
            return((IntPtr)0);
        }