예제 #1
0
        public static List <PluginCommunicationResponse> SendToAll(this ICommunicationEnabledPlugin sender, string command, params object[] args)
        {
            var result = new List <PluginCommunicationResponse>();

            IEnumerable <IPlugin> plugins;

            if (Method == "Reflection")
            {
                plugins = CommunicationEnabledPluginsViaReflection;
            }
            else
            {
                plugins = CommunicationEnabledPlugins;
            }
            foreach (var plugin in plugins.Where(p => !String.Equals(p.Name, sender.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                try
                {
                    if (Method == "Reflection")
                    {
                        var receiveMethod = GetReceiveMethod(plugin);
                        if (receiveMethod != null)
                        {
                            result.Add(receiveMethod.InvokeReceive(sender, plugin, command, args));
                        }
                    }
                    else
                    {
                        result.Add(((ICommunicationEnabledPlugin)plugin).Receive(sender, command, args));
                    }
                }
                catch (Exception ex)
                {
                    //Log something?
                    result.Add(new PluginCommunicationResponse(plugin, PluginCommunicationResult.PluginReceiveError.ToString()));
                }
            }
            return(result);
        }
예제 #2
0
        public static PluginCommunicationResponse Send(this ICommunicationEnabledPlugin sender, string pluginName, string command, params object[] args)
        {
            IPlugin plugin;

            if (Method == "Reflection")
            {
                plugin = CommunicationEnabledPluginsViaReflection.FirstOrDefault(p => String.Equals(p.Name, pluginName, StringComparison.InvariantCultureIgnoreCase));
            }
            else
            {
                plugin = CommunicationEnabledPlugins.FirstOrDefault(p => String.Equals(p.Name, pluginName, StringComparison.InvariantCultureIgnoreCase));
            }
            if (plugin == null)
            {
                return(PluginNotExistsResponse);
            }
            try
            {
                if (Method == "Reflection")
                {
                    var receiveMethod = GetReceiveMethod(plugin);
                    if (receiveMethod != null)
                    {
                        return(receiveMethod.InvokeReceive(sender, plugin, command, args));
                    }
                    return(new PluginCommunicationResponse(null, PluginCommunicationResult.PluginNotExists.ToString()));
                }
                else
                {
                    return(((ICommunicationEnabledPlugin)plugin).Receive(sender, command, args));
                }
            }
            catch (Exception ex)
            {
                //Log something?
                return(new PluginCommunicationResponse(plugin, PluginCommunicationResult.PluginReceiveError.ToString()));
            }
        }
예제 #3
0
 static PluginCommunicator()
 {
     Me = AutoFollow.Instance;
 }
예제 #4
0
 static PluginCommunicator()
 {
     Me = Trinity.Instance;
 }
예제 #5
0
 static PluginCommunicator()
 {
     Me = Adventurer.CurrentInstance;
     CoroutineQueue.Enable();
 }
예제 #6
0
 static PluginCommunicator()
 {
     Me = Adventurer.CurrentInstance;
 }