/// <summary> /// Aids in removal of module parses. /// </summary> /// <param name="p">The parse to check for removal.</param> private bool UnregisterPredicate(IRCEvents.Parse p) { return p.Function.Method.Module.Equals( instanceOfModule.GetType().Module ); }
/// <summary> /// Enables a module to register a parse that will be activated on /// the events specified by the parsetype. /// </summary> /// <param name="parse">The parse to register.</param> /// <param name="serverid">The server to register the parse to.</param> /// <param name="d">The function to call.</param> /// <param name="parseType">The events to add the parse to.</param> public void RegisterWildcardParse(string parse, int serverid, CrossAppDomainDelegate d, IRCEvents.ParseTypes parseType) { IRCEvents.Parse p = new IRCEvents.Parse( parse, d, parseType, instanceOfModule.GetType().GetField("parseReturns", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.SetField ), instanceOfModule ); IRCEvents serversIrcEvents = (IRCEvents)RequestVariable( Request.IRCEvents, serverid ); serversIrcEvents.WildcardParses.Add( p ); }
/// <summary> /// Enables a module to register a parse that will be activated on /// the events specified by the parsetype on all servers. /// </summary> /// <param name="parse">The parse to register.</param> /// <param name="d">The function to call.</param> /// <param name="parseType">The events to add the parse to.</param> public void RegisterWildcardParse(string parse, CrossAppDomainDelegate d, IRCEvents.ParseTypes parseType) { IRCEvents.Parse p = new IRCEvents.Parse( parse, d, parseType, instanceOfModule.GetType().GetField( "parseReturns", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.SetField ), instanceOfModule ); for ( int i = 0; i < IModule.MaxServers; i++ ) { IRCEvents serversIrcEvents = (IRCEvents)RequestVariable( Request.IRCEvents, i ); if ( serversIrcEvents == null ) break; serversIrcEvents.WildcardParses.Add( p ); } }
/// <summary> /// Enables a module to register a parse that will be activated on /// the events specified by the parsetype on all servers. /// </summary> /// <param name="parse">The parse to register.</param> /// <param name="d">The function to call.</param> /// <param name="parseType">The events to add the parse to.</param> public void RegisterParse(string parse, CrossAppDomainDelegate d, IRCEvents.ParseTypes parseType) { IRCEvents.Parse p = new IRCEvents.Parse( parse, d, parseType, instanceOfModule.GetType().GetField( "parseReturns", BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.SetField ), instanceOfModule ); for ( int k = 0; k < IModule.MaxServers; k++ ) { IRCEvents serversIrcEvents = (IRCEvents)RequestVariable( Request.IRCEvents, k ); if ( serversIrcEvents == null ) break; if ( serversIrcEvents.Parses.Count == 0 ) serversIrcEvents.Parses.Add( p ); else { for ( int i = 0; i < serversIrcEvents.Parses.Count; i++ ) if ( serversIrcEvents.Parses[i].ParseString.CompareTo( parse ) >= 0 ) { serversIrcEvents.Parses.Insert( i, p ); //I hope to god this shoves to the right and not the left. return; } serversIrcEvents.Parses.Insert( serversIrcEvents.Parses.Count - 1, p ); } } }