private static IMessenger AddMessage(
            this IMessenger value,
            string text,
            string type,
            string title = null)
        {
            value.Add(new Message(text, title, type));

            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The handling.
        /// </summary>
        /// <param name="exception">
        /// The exception.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool Handling(Exception exception)
        {
            if (exception is COMException)
            {
                messenger.Add(new UiMessage(WiaError.GetErrorMessage((COMException)exception), TypeOfMessage.Error));
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            var messageProvider  = new InMemoryMessageProvider();
            var messengerOptions = new MessengerOptions(messageTypes);

            messenger = new StackMessenger(messageProvider, messengerOptions);

            var input = string.Empty;

            do
            {
                PrintHeader();

                input = System.Console.ReadLine();

                var now = System.DateTime.UtcNow;

                if (input == "e")
                {
                    messenger.Add(new Message("An error has occured", now.ToString(), messageTypes.Error));
                }
                else if (input == "i")
                {
                    messenger.Add(new Message("This is an information message.", now.ToString(), messageTypes.Information));
                }
                else if (input == "s")
                {
                    messenger.Add(new Message("Congraulations!", now.ToString(), messageTypes.Success));
                }
                else if (input == "w")
                {
                    messenger.Add(new Message("Be careful.", now.ToString(), messageTypes.Warning));
                }
                else if (input == "p")
                {
                    PrintMessages();
                }

                System.Console.WriteLine("");
            } while (input != "q");
        }