示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UserInterfaceService"/> class.
        /// </summary>
        /// <param name="container">The container that stores all the references for the application.</param>
        /// <param name="onStartService">
        ///     The method that stores the IOC container that contains the references for the entire application.
        /// </param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="container"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// Thrown when <paramref name="onStartService"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public UserInterfaceService(IContainer container, Action <IContainer> onStartService, SystemDiagnostics diagnostics)
            : base(diagnostics)
        {
            {
                Enforce.Argument(() => container);
                Enforce.Argument(() => onStartService);
            }

            m_Container         = container;
            m_NotificationNames = container.Resolve <INotificationNameConstants>();
            m_Diagnostics       = container.Resolve <SystemDiagnostics>();
            m_OnStartService    = onStartService;

            m_Commands = container.Resolve <ICommandContainer>();
            {
                m_Commands.Add(
                    ShutdownApplicationCommand.CommandId,
                    () => new ShutdownApplicationCommand(() => m_Core.Shutdown()));

                m_Commands.Add(
                    CreateProjectCommand.CommandId,
                    () => new CreateProjectCommand(
                        () =>
                {
                    m_Projects.CreateNewProject();
                    return(m_Projects.Current);
                }));

                m_Commands.Add(
                    LoadProjectCommand.CommandId,
                    () => new LoadProjectCommand(
                        persistenceInformation =>
                {
                    m_Projects.LoadProject(persistenceInformation);
                    return(m_Projects.Current);
                }));

                m_Commands.Add(
                    UnloadProjectCommand.CommandId,
                    () => new UnloadProjectCommand(() => m_Projects.UnloadProject()));
            }
        }