Example #1
0
        static DispatchImpl ReadDispatch(XmlSetting xmlSetting, int level, log4net.ILog logger)
        {
            if (null == xmlSetting)
            {
                return(null);
            }

            string value = xmlSetting.ReadSetting("@value", null);
            string alias = xmlSetting.ReadSetting("@alias", null);
            string key   = xmlSetting.ReadSetting("@key", null);

            if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(key))
            {
                return(null);
            }

            DispatchImpl impl = new DispatchImpl();

            impl.Result.Key       = key;
            impl.Result.Value     = value;
            impl.Result.Alias     = alias;
            impl.Result.Separator = xmlSetting.ReadSetting("@separator", null);
            impl.Result.Dynamic   = xmlSetting.ReadSetting("@dynamic", null);

            logger.Logger.Log(typeof(Dispatcher), log4net.Core.Level.Verbose, string.Format("{0} key={1},value={2},alias={3},separator={4},dynamic={5}"
                                                                                            , new string(' ', level)
                                                                                            , impl.Result.Key
                                                                                            , impl.Result.Value
                                                                                            , impl.Result.Alias
                                                                                            , impl.Result.Separator
                                                                                            , impl.Result.Dynamic), null);

            if (string.IsNullOrEmpty(key))
            {
                return(impl);
            }

            foreach (XmlSetting child in xmlSetting.Select("*"))
            {
                DispatchImpl ch = ReadDispatch(child, ++level, logger);
                if (null == ch)
                {
                    continue;
                }

                impl.Childs[ch.Result.Value] = ch;
            }
            return(impl);
        }
Example #2
0
 public static void ReadDispatch(XmlSetting xmlSetting, Dispatcher dispatcher, log4net.ILog logger)
 {
     dispatcher.Key = xmlSetting.ReadSetting("@key", null);
     if (string.IsNullOrEmpty(dispatcher.Key))
     {
         return;
     }
     foreach (XmlSetting child in xmlSetting.Select("*"))
     {
         DispatchImpl ch = ReadDispatch(child, 1, logger);
         if (null == ch)
         {
             continue;
         }
         dispatcher.Childs[ch.Result.Value] = ch;
     }
 }