コード例 #1
0
        public string NotifyMessage(string language = null)//Message message)
        {
            INotifier notifier     = new ConsoleNotifier();
            string    notifierType = "none";

            try
            {
                notifierType = ConfigurationManager.AppSettings["NotifierType"];
            }
            catch (Exception) { }

            Message message = GetNotificationMessage();// Language.GetFromResourceFile("BaseHelloMessage");// "Hello World";


            if (notifierType.ToUpper().Trim() == "CONSOLE")
            {
                notifier = new ConsoleNotifier();
            }
            else if (notifierType.ToUpper().Trim() == "FILE")
            {
                notifier = new FileNotifier();
            }
            else if (notifierType.ToUpper().Trim() == "DB")
            {
                notifier = new DBNotifier();
            }
            else
            {
                notifier = new Notifier();
            }
            return(NotifyMessage(message, notifier));
        }
コード例 #2
0
        public async Task Basic()
        {
            var path = $"{new FuzzRandom().Uniform(0, int.MaxValue)}.txt";

            var notifier = new FileNotifier(TestFormatter.Instance, _ => path);
            await notifier.NotifyCounterexampleAsync(new Counterexample(Mock.Of <MethodInfo>(), new List <Argument>()));

            var output = await File.ReadAllTextAsync(path, Encoding.UTF8);

            Assert.IsTrue(output.Contains(TestFormatter.GeneratedString));

            File.Delete(path);
        }
コード例 #3
0
        public string Notify(IConfigurationManager configurationManager)
        {
            if (configurationManager == null)
            {
                throw new ArgumentNullException("configurationManager");
            }

            INotifier notifier     = new ConsoleNotifier();
            string    notifierType = "none";

            try
            {
                notifierType = configurationManager.GetAppSetting("NotifierType");
                // notifierType =  ConfigurationManager.AppSettings["NotifierType"];
            }
            catch (Exception) { }

            Message message = new Message();

            message.messageText = Language.GetFromResourceFile("BaseHelloMessage");// "Hello World";


            if (notifierType.ToUpper().Trim() == "CONSOLE")
            {
                notifier = new ConsoleNotifier();
            }
            else if (notifierType.ToUpper().Trim() == "FILE")
            {
                notifier = new FileNotifier();
            }
            else if (notifierType.ToUpper().Trim() == "DB")
            {
                notifier = new DBNotifier();
            }
            else
            {
                notifier = new Notifier();
            }
            return(NotifyMessage(message, notifier));
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: dansam100/Logger
        static void Main(string[] args)
        {
            //TODO: Write LogLog class for internal logging of unhandled exceptions and failures.
            string pattern = Console.ReadLine();
            //ITokenizer t = new Tokenizer(pattern);
            //t.SetValue(Formatter.TokenType.content, "hahaha");
            //ConsoleNotifier cn = new ConsoleNotifier();
            FileNotifier fn = new FileNotifier(true);
            //cn.Threshold = Level.All;

            //ILog logger = LogManager.GetLogger(new Logger.Program().GetType().ToString());

            LogInfo info = new LogInfo("this is the message", new Logger.Program().GetType(), Level.All, "thisLogger", new ArgumentException(), DateTime.Now, null);
            Log     log  = new Log(info);

            //logger.Debug("this is an exception message", new ArgumentException());

            //cn.Append(log);
            //cn.Append(log);
            fn.Append(log);
            fn.Append(log);
            fn.Exit();
        }