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); }
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())); } }
static PluginCommunicator() { Me = AutoFollow.Instance; }
static PluginCommunicator() { Me = Trinity.Instance; }
static PluginCommunicator() { Me = Adventurer.CurrentInstance; CoroutineQueue.Enable(); }
static PluginCommunicator() { Me = Adventurer.CurrentInstance; }