Meta.MetaPackage.Initialize C# (CSharp) Method

Initialize() protected method

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.
protected Initialize ( ) : void
return void
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if(null != mcs)
            {
                // Create the command for the menu item.
                CommandID menuCommandID = new CommandID(GuidList.guidMetaCmdSet1, (int)PkgCmdIDList.cmdidMetaUIContext1);
                OleMenuCommand menuItem = new OleMenuCommand(BuildProfileCallback, menuCommandID);
                menuItem.BeforeQueryStatus += uiContex1Cmd_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                menuCommandID = new CommandID(GuidList.guidMetaCmdSet1, (int)PkgCmdIDList.cmdidMetaUIContext3);
                menuItem = new OleMenuCommand(GenerateBoostBuildFileCallback, menuCommandID);
                menuItem.BeforeQueryStatus += uiContex3Cmd_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                menuCommandID = new CommandID(GuidList.guidMetaCmdSet2, (int)PkgCmdIDList.cmdidMetaUIContext1);
                menuItem = new OleMenuCommand(BuildProfileCallback, menuCommandID);
                menuItem.BeforeQueryStatus += uiContex1Cmd_BeforeQueryStatus;
                mcs.AddCommand(menuItem);

                menuCommandID = new CommandID(GuidList.guidMetaCmdSet2, (int)PkgCmdIDList.cmdidMetaUIContext2);
                menuItem = new OleMenuCommand(TemplateProfileCallback, menuCommandID);
                menuItem.BeforeQueryStatus += uiContex2Cmd_BeforeQueryStatus;
                mcs.AddCommand(menuItem);
            }

            // Get shell object
            vsShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsShell)) as IVsShell;
            if(vsShell != null)
                vsShell.AdviseShellPropertyChanges(this, out shellPropertyChangesCookie);

            // Get solution
            solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            if(solution != null)
            {
                // Get count of any currently loaded projects
                object count;
                solution.GetProperty((int)__VSPROPID.VSPROPID_ProjectCount, out count);

                // Register for solution events
                solution.AdviseSolutionEvents(this, out solutionEventsCookie);
            }

            // Get solution build manager
            sbm = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2;
            if(sbm != null)
                sbm.AdviseUpdateSolutionEvents(this, out updateSolutionEventsCookie);
        }