Exemplo n.º 1
0
        public static void CreateNew(IArguments arguments)
        {
            // Validate the mandatory input params
            if (!arguments.ContainsKey("type"))
            {
                throw new ArgumentException("-type not provided");
            }

            if (!arguments.ContainsKey("port"))
            {
                throw new ArgumentException("-port not provided");
            }

            if (!arguments.ContainsKey("host"))
            {
                throw new ArgumentException("-host not provided");
            }

            if (!arguments.ContainsKey("username"))
            {
                throw new ArgumentException("-username not provided");
            }

            if (!arguments.ContainsKey("password"))
            {
                throw new ArgumentException("-password not provided");
            }

            if (_current == null)
            {
                _current = new UnitTestContext(arguments);
            }
        }
Exemplo n.º 2
0
        public static void CreateNew(IArguments arguments)
        {
            // Validate the mandatory input params
            if (!arguments.ContainsKey("type"))
                throw new ArgumentException("-type not provided");

            if (!arguments.ContainsKey("port"))
                throw new ArgumentException("-port not provided");

            if (!arguments.ContainsKey("host"))
                throw new ArgumentException("-host not provided");

            if (!arguments.ContainsKey("username"))
                throw new ArgumentException("-username not provided");

            if (!arguments.ContainsKey("password"))
                throw new ArgumentException("-password not provided");

            if (_current == null)
                _current = new UnitTestContext(arguments);
        }
Exemplo n.º 3
0
        private UnitTestContext(IArguments arguments)
        {
            if (arguments == null)
                throw new InvalidOperationException(
                    "Current Context could not be initialized. No arguments passed to the context");

            var element = new LogElement
            {
                Parameters = "-ShowOnConsole:true ",
                ProviderType = "KonfDB.Infrastructure.Logging.Logger, KonfDBC"
            };

            if (arguments.ContainsKey("runtime-logConfigPath"))
                element.Parameters += "-path:" + arguments["runtime-logConfigPath"];

            var logger = LogFactory.CreateInstance(element);

            CurrentContext.CreateDefault(logger, arguments, null);
        }
Exemplo n.º 4
0
        public Logger(IArguments args)
            : base(args)
        {
            if (args.ContainsKey("logConfigPath") && File.Exists(args["logConfigPath"]))
            {
                XmlConfigurator.Configure(new FileInfo(args["logConfigPath"]));
                _log = LogManager.GetLogger("KonfDB");
            }
            else
            {
                _log = LogManager.GetLogger("KonfDB");
                var appenders = new List<IAppender> {CreateFileAppender("FileAppender", @"Logs\KonfDB.log")};

                if (args.GetValue("ShowOnConsole", "false")
                    .Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase))
                    appenders.Add(CreateConsoleAppender());

                BasicConfigurator.Configure(appenders.ToArray());
            }
        }
Exemplo n.º 5
0
        private UnitTestContext(IArguments arguments)
        {
            if (arguments == null)
            {
                throw new InvalidOperationException(
                          "Current Context could not be initialized. No arguments passed to the context");
            }

            var element = new LogElement
            {
                Parameters   = "-ShowOnConsole:true ",
                ProviderType = "KonfDB.Infrastructure.Logging.Logger, KonfDBC"
            };

            if (arguments.ContainsKey("runtime-logConfigPath"))
            {
                element.Parameters += "-path:" + arguments["runtime-logConfigPath"];
            }

            var logger = LogFactory.CreateInstance(element);

            CurrentContext.CreateDefault(logger, arguments, null);
        }
Exemplo n.º 6
0
        public Logger(IArguments args)
            : base(args)
        {
            if (args.ContainsKey("logConfigPath") && File.Exists(args["logConfigPath"]))
            {
                XmlConfigurator.Configure(new FileInfo(args["logConfigPath"]));
                _log = LogManager.GetLogger("KonfDB");
            }
            else
            {
                _log = LogManager.GetLogger("KonfDB");
                var appenders = new List <IAppender> {
                    CreateFileAppender("FileAppender", @"Logs\KonfDB.log")
                };

                if (args.GetValue("ShowOnConsole", "false")
                    .Equals(bool.TrueString, StringComparison.InvariantCultureIgnoreCase))
                {
                    appenders.Add(CreateConsoleAppender());
                }

                BasicConfigurator.Configure(appenders.ToArray());
            }
        }
Exemplo n.º 7
0
 public bool HasArgument(string key)
 {
     return(Args.ContainsKey(key));
 }