Defines the VSInstance type.
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            TraceService.WriteLine("NinjaCoder_MvvmCross_VSPackagePackage::Initialize");

            base.Initialize();

            DTE2 dte2 = (DTE2)this.GetService(typeof(DTE2));

            this.VsInstance = new VSInstance(dte2);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = this.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs == null)
            {
                return;
            }

            // Create the command for the menu item.
            CommandID menuCommandId = new CommandID(GuidList.guidNinjaCoder_MvvmCross_VSPackageCmdSet, (int)PkgCmdIDList.NinjaCoderForMvvmCrossCommand);
            MenuCommand menuItem = new MenuCommand(this.MenuItemCallback, menuCommandId);
            mcs.AddCommand(menuItem);
        }
        /// <summary>
        /// Called when [connection].
        /// </summary>
        /// <param name="application">The application.</param>
        /// <param name="connectMode">The connect mode.</param>
        /// <param name="addInInst">The add in inst.</param>
        /// <param name="custom">The custom.</param>
        public void OnConnection(
            object application, 
            ext_ConnectMode connectMode, 
            object addInInst, 
            ref Array custom)
        {
            this.VSInstance = new VSInstance((DTE2)application);
            this.AddInInstance = (AddIn)addInInst;

            TraceService.WriteLine("--------------------------------------------------------");
            TraceService.WriteLine("CommandManager::OnConnection ConnectMode=" + connectMode);
            TraceService.WriteLine("--------------------------------------------------------");

            switch (connectMode)
            {
                case ext_ConnectMode.ext_cm_UISetup:
                    //// Do nothing for this add-in with temporary user interface

                    //// Initialize for permanent user interface

                    this.UISetup();
                    this.Initialize();
                    break;

                case ext_ConnectMode.ext_cm_Startup:
                    //// The add-in was marked to load on startup
                    //// Do nothing at this point because the IDE may not be fully initialized
                    //// Visual Studio will call OnStartupComplete when fully initialized

                    this.StartUp();
                    this.Initialize();
                    break;

                case ext_ConnectMode.ext_cm_AfterStartup:
                    //// The add-in was loaded by hand after startup using the Add-In Manager
                    //// Initialize it in the same way that when is loaded on startup

                    this.AfterStartUp();
                    this.Initialize();
                    break;
            }
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            TraceService.WriteLine("NinjaCoder_MvvmCross_VSPackagePackage::Initialize START");

            base.Initialize();

            DTE2 dte2 = this.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SDTE)) as DTE2;

            if (dte2 == null)
            {
                TraceService.WriteError("DTE2 is null from this.GetService(typeof(DTE2))");
            }

            this.VsInstance = new VSInstance(dte2);

            string assemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            TraceService.WriteLine("assembly path=" + assemblyPath);

            NinjaController.SetWorkingDirectory(Path.GetDirectoryName(assemblyPath));

            OleMenuCommandService mcs = this.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs == null)
            {
                TraceService.WriteError("NinjaCoder_MvvmCross_VSPackagePackage::menuCommandService is null");
                return;
            }

            CommandID menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddProjects);
            MenuCommand menuItem = new MenuCommand(this.OnAddProjects, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddViewModelsAndViews);
            menuItem = new MenuCommand(this.OnAddViewModelAndViews, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddMvvmCrossPlugins);
            menuItem = new MenuCommand(this.OnAddMvvmCrossPlugins, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddNugetPackages);
            menuItem = new MenuCommand(this.OnAddNugetPackages, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddDependencyService);
            menuItem = new MenuCommand(this.OnAddDependencyService, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddCustomRenderer);
            menuItem = new MenuCommand(this.OnAddCustomerRenderer, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.AddEffect);
            menuItem = new MenuCommand(this.OnAddEffect, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.Options);
            menuItem = new MenuCommand(this.OnOptions, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ViewLogFile);
            menuItem = new MenuCommand(this.OnViewLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ClearLogFile);
            menuItem = new MenuCommand(this.OnClearLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ViewErrorLog);
            menuItem = new MenuCommand(this.OnViewErrorLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.ClearErrorLog);
            menuItem = new MenuCommand(this.OnClearErrorLogFile, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.XamarinFormsHomePage);
            menuItem = new MenuCommand(this.OnXamarinFormsHomePage, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.MvvmCrossHomePage);
            menuItem = new MenuCommand(this.OnMvvmCrossHomePage, menuCommandId);
            mcs.AddCommand(menuItem);

            menuCommandId = new CommandID(GuidList.GuidNinjaCoderMvvmCrossVsPackageCmdSet, (int)PkgCmdIdList.About);
            menuItem = new MenuCommand(this.OnAbout, menuCommandId);
            mcs.AddCommand(menuItem);

            TraceService.WriteLine("NinjaCoder_MvvmCross_VSPackagePackage::Initialize END");
        }