예제 #1
0
        /// <summary>
        /// Registers the specified command handler.
        /// </summary>
        public void Register(ISECSIIMessageHandler secsIIMessageHandler)
        {
            //Only SxFx method name
            string pattern  = @"^S[0-9]{1,3}F[0-9]{1,3}$";
            var    handlers = (from item in secsIIMessageHandler.GetType().GetMethods()
                               where Regex.IsMatch(item.Name, pattern) && item.IsPublic && item.ReturnType == typeof(bool)
                               select new GemHandler {
                Name = item.Name, Handler = (Func <XElement, bool>)Delegate.CreateDelegate(typeof(Func <XElement, bool>), secsIIMessageHandler, item)
            }).ToList();

            if (_handlers.Keys.Any(n => handlers.Any(b => b.Name == n)))
            {
                throw new ArgumentException("The SECSII message handled by the received handler already has a registered handler.");
            }

            // Register this handler for each of the handler's name
            handlers.ForEach(h => _handlers.Add(h.Name, h.Handler));
        }
예제 #2
0
 /// <summary>
 /// Registers the specified SECSII message handler.
 /// </summary>
 public void Register(ISECSIIMessageHandler handler)
 {
     _secsIIMessageDispatcher.Register(handler);
 }