Exemplo n.º 1
0
        /// <summary>
        /// 通过 Descript 对象获取其对应的解释器。
        /// </summary>
        /// <param name="desObj">命令描述对象。</param>
        /// <returns></returns>
        public ParserBase GetParserByObject(IDescription desObj)
        {
            ParserBase parser = Get(desObj.GetType());

            if (parser != null)
            {
                parser.Description = desObj;
            }
            return(parser);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 注册命令解释器.
 /// </summary>
 /// <param name="forDescription">解释器所针对的命令描述对象.</param>
 /// <param name="parser">注册该命令解释器的对象实例.</param>
 protected void RegisterParser(Type forDescription, ParserBase parser)
 {
     if (Parsers.ContainsKey(forDescription))
     {
         Parsers[forDescription] = parser;
     }
     else
     {
         Parsers.Add(forDescription, parser);
     }
 }