private static UnityContainer CreateIocContainer(DTE2 dte)
        {
            var logger = new OutputWindowLogger(dte);
            logger.WriteInfo("Loading Mabado... Connect to lab");

            var branchProvider = new BranchPathProvider(dte);

            UnityContainer container = new UnityContainer();
            container.RegisterInstance<ILogger>(logger);
            container.RegisterInstance(new SourceControlAdapter(dte.SourceControl));
            container.RegisterInstance<IPathProvider>(branchProvider);
            container.RegisterType<ViewsContainer, ViewsContainer>(new ContainerControlledLifetimeManager());
            return container;
        }
示例#2
0
文件: Connect.cs 项目: yanivru/Mabado
        /// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary>
        /// <param term='commandName'>The name of the command to execute.</param>
        /// <param term='executeOption'>Describes how the command should be run.</param>
        /// <param term='varIn'>Parameters passed from the caller to the command handler.</param>
        /// <param term='varOut'>Parameters passed from the command handler to the caller.</param>
        /// <param term='handled'>Informs the caller if the command was handled or not.</param>
        /// <seealso class='Exec' />
        public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
        {
            handled = false;
            if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
            {
                IPathProvider serverPathProvider = new BranchPathProvider(_applicationObject);

                MabadoViewBootLoader viewBootLoader = new MabadoViewBootLoader(serverPathProvider, _applicationObject.SourceControl, new OutputWindowLogger(_applicationObject));

                if(commandName == "Mabado.Connect.ConnectToLab")
                {
                    if(_applicationObject.Solution.IsOpen)
                    {
                        viewBootLoader.ConnectToLab();
                    }
                    else
                    {
                        MessageBox.Show("Open solution first.", "MabaDo", MessageBoxButtons.OK);
                    }

                    handled = true;
                }

                if (commandName == "Mabado.Connect.OpenSolution")
                {
                    if(_applicationObject.Solution.IsOpen)
                    {
                        viewBootLoader.LaunchSolution();
                    }
                    else
                    {
                        MessageBox.Show("Open solution first.", "MabaDo", MessageBoxButtons.OK);
                    }

                    handled = true;
                }
            }
        }