Esempio 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);
            }
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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());
            }
        }
Esempio 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);
        }
Esempio 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());
            }
        }
Esempio n. 7
0
 public bool HasArgument(string key)
 {
     return(Args.ContainsKey(key));
 }