Exemplo n.º 1
0
        /// <summary>
        /// Shuts the application down.
        /// </summary>
        public void Shutdown()
        {
            if (m_IsApplicationShuttingDown)
            {
                return;
            }

            m_Diagnostics.Log(
                LevelToLog.Trace,
                HostConstants.LogPrefix,
                Resources.UserInterface_LogMessage_ShuttingDown);

            var context = new ShutdownApplicationContext();

            try
            {
                Debug.Assert(m_Service.Contains(ShutdownApplicationCommand.CommandId), "A command has gone missing.");
                m_Service.Invoke(ShutdownApplicationCommand.CommandId, context);
            }
            catch (ArgumentException e)
            {
                m_Diagnostics.Log(
                    LevelToLog.Error,
                    HostConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.UserInterface_LogMessage_ShutDownFailed_WithError,
                        e));
            }
        }
        public void Invoke()
        {
            bool wasInvoked = false;

            Action function = () =>
                {
                    wasInvoked = true;
                };
            var command = new ShutdownApplicationCommand(function);

            var context = new ShutdownApplicationContext();
            command.Invoke(context);
            Assert.IsTrue(wasInvoked);
        }
        public void Invoke()
        {
            bool wasInvoked = false;

            Action function = () =>
            {
                wasInvoked = true;
            };
            var command = new ShutdownApplicationCommand(function);

            var context = new ShutdownApplicationContext();

            command.Invoke(context);
            Assert.IsTrue(wasInvoked);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Shuts the application down.
        /// </summary>
        public void Shutdown()
        {
            if (m_IsApplicationShuttingDown)
            {
                return;
            }

            m_Diagnostics.Log(
                LevelToLog.Trace,
                HostConstants.LogPrefix,
                Resources.UserInterface_LogMessage_ShuttingDown);

            var context = new ShutdownApplicationContext();

            try
            {
                Debug.Assert(m_Service.Contains(ShutdownApplicationCommand.CommandId), "A command has gone missing.");
                m_Service.Invoke(ShutdownApplicationCommand.CommandId, context);
            }
            catch (ArgumentException e)
            {
                m_Diagnostics.Log(
                    LevelToLog.Error,
                    HostConstants.LogPrefix,
                    string.Format(
                        CultureInfo.InvariantCulture,
                        Resources.UserInterface_LogMessage_ShutDownFailed_WithError,
                        e));
            }
        }