Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 /// <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));
 }
Esempio n. 4
0
 public Pattern(int id, PatternMatchFunc b, string pattern, params object[] args)
 {
     ID = id; Func = b; Term = ErlObject.Parse(pattern, args);
 }
Esempio n. 5
0
 public Pattern(int id, PatternMatchFunc b, IErlObject p)
 {
     ID = id; Func = b; Term = p;
 }
Esempio n. 6
0
 /// <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));
 }