/// <summary> /// Add a matching pattern to the collection /// </summary> /// <param name="pattern">Erlang term to be used as a match pattern</param> /// <param name="func">Function to invoke on successful match</param> /// <returns>ID of the newly added pattern</returns> public int Add(IErlObject pattern, PatternMatchFunc func) { int id = ++m_lastID; var pt = new Pattern(id, (p, t, b, args) => func(p, t, b, args), pattern); m_patterns.Add(pt); return(id); }
/// <summary> /// Add a matching pattern to the collection /// </summary> /// <typeparam name="TContext">Type of context passed to func</typeparam> /// <param name="context">Context passed to func</param> /// <param name="pattern">Compiled pattern containing variables to match</param> /// <param name="func">Function to invoke on successful match</param> /// <returns>ID of the newly added pattern</returns> public int Add <TContext>(TContext context, IErlObject pattern, PatternMatchFunc <TContext> func) { int id = ++m_lastID; var pt = new Pattern(id, (p, t, b, args) => func(context, p, t, b, args), pattern); m_patterns.Add(pt); return(id); }
/// <summary> /// Add a matching pattern to the collection /// </summary> /// <param name="pattern">Pattern to compile</param> /// <param name="func">Function to invoke on successful match</param> /// <returns>ID of the newly added pattern</returns> public int Add(string pattern, PatternMatchFunc func) { return(Add(ErlObject.Parse(pattern), func)); }
public Pattern(int id, PatternMatchFunc b, string pattern, params object[] args) { ID = id; Func = b; Term = ErlObject.Parse(pattern, args); }
public Pattern(int id, PatternMatchFunc b, IErlObject p) { ID = id; Func = b; Term = p; }
/// <summary> /// Add a matching pattern to the collection /// </summary> /// <typeparam name="TContext">Type of context passed to func</typeparam> /// <param name="context">Context passed to func</param> /// <param name="pattern">Pattern to compile</param> /// <param name="func">Function to invoke on successful match</param> /// <returns>ID of the newly added pattern</returns> public int Add <TContext>(TContext context, string pattern, PatternMatchFunc <TContext> func) { return(Add(context, ErlObject.Parse(pattern), func)); }