Пример #1
0
        public Log ResolveLog(string name)
        {
            LogDefinition log     = Logs[name];
            TypeCreator   creator = new TypeCreator(log.Type);

            foreach (var formatterProperty in log.Properties)
            {
                creator.MemberValues.Add(formatterProperty.Key, formatterProperty.Value);
            }

            var value = (Log)creator.Create();

            foreach (var logListenerName in log.ListenerNames)
            {
                if (Listeners.ContainsKey(logListenerName))
                {
                    value.AddListener(ResolveListener(logListenerName));
                    continue;
                }
                else
                {
                    bool added = false;
                    foreach (var configuration in Imports)
                    {
                        if (configuration.Listeners.ContainsKey(logListenerName))
                        {
                            value.AddListener(configuration.ResolveListener(logListenerName));
                            added = true;
                            break;
                        }
                    }
                    if (added)
                    {
                        continue;
                    }
                }
                throw new KeyNotFoundException("Listener '" + logListenerName + "' not found in configuration or imports.");
            }

            if (Formatters.ContainsKey(log.FormatterName))
            {
                value.Formatter = ResolveFormatter(log.FormatterName);
            }
            else
            {
                foreach (var configuration in Imports)
                {
                    if (configuration.Formatters.ContainsKey(log.FormatterName))
                    {
                        value.Formatter = configuration.ResolveFormatter(log.FormatterName);
                        break;
                    }
                }
            }

            return(value);
        }
Пример #2
0
        public MessageSink ResolveSink(string name)
        {
            SinkDefinition sink    = Sinks[name];
            TypeCreator    creator = new TypeCreator(sink.Type);

            foreach (var formatterProperty in sink.Properties)
            {
                creator.MemberValues.Add(formatterProperty.Key, formatterProperty.Value);
            }

            return((MessageSink)creator.Create());
        }
Пример #3
0
        public Listener ResolveListener(string name)
        {
            ListenerDefinition listener = Listeners[name];
            TypeCreator        creator  = new TypeCreator(listener.Type);

            foreach (var formatterProperty in listener.Properties)
            {
                creator.MemberValues.Add(formatterProperty.Key, formatterProperty.Value);
            }

            return((Listener)creator.Create());
        }