protected override void Initialize()
        {
            base.Initialize();
            _dte = GetService(typeof(DTE)) as DTE2;
            _activityLogger = new ActivityLogger(GetService(typeof(SVsActivityLog)) as IVsActivityLog);

            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
                OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId);
                button.BeforeQueryStatus += button_BeforeQueryStatus;
                mcs.AddCommand(button);

                CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.SWMenuGroup);
                OleMenuCommand menuItem = new OleMenuCommand(OpenSettings, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            System.Threading.Tasks.Task.Run(async () => {
                await System.Threading.Tasks.Task.Delay(100);
                
                try {
                    new DynamicTemplateBuilder(_dte, _activityLogger).ProcessTemplates();
                }
                catch (Exception ex) {
                    _activityLogger.Error(ex.ToString());
                    _dte.StatusBar.Text = @"An error occured while updating templates, check the activity log";

                    // Leave this for now until we are sure activity logger above works well
                    System.Windows.MessageBox.Show(ex.ToString());
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// If dte is null it will be ignored
        /// If activityLogger is null it will be ignored.
        /// </summary>
        /// <param name="dte"></param>
        public DynamicTemplateBuilder(DTE2 dte, ActivityLogger activityLogger) {
            // Note: using extensions install dir causes max path issues
            //this.SourceRoot = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\sources\");
            //this.BaseIntermediateOutputPath = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\baseintout\");
            //this.OutputPath = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\output\");

            var verstr = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version.ToString();
            var rootDir = Environment.ExpandEnvironmentVariables(
                            string.Format(@"%localappdata%\LigerShark\SideWaffle\DynamicTemplates\{0}\", verstr));

            this.RootDirectory = Path.GetFullPath(rootDir);
            this.SourceRoot = Path.Combine(rootDir, @"sources\");
            this.BaseIntermediateOutputPath = Path.Combine(rootDir, @"baseintout\");
            this.OutputPath = Path.Combine(rootDir, @"output\");
            this.Dte = dte;
            this.ActivityLog = activityLogger;
        }
        /// <summary>
        /// If dte is null it will be ignored
        /// If activityLogger is null it will be ignored.
        /// </summary>
        /// <param name="dte"></param>
        public DynamicTemplateBuilder(DTE2 dte, ActivityLogger activityLogger)
        {
            // Note: using extensions install dir causes max path issues
            //this.SourceRoot = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\sources\");
            //this.BaseIntermediateOutputPath = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\baseintout\");
            //this.OutputPath = Path.Combine(SideWaffleInstallDir, @"DynamicTemplates\output\");

            var verstr  = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version.ToString();
            var rootDir = Environment.ExpandEnvironmentVariables(
                string.Format(@"%localappdata%\LigerShark\SideWaffle\DynamicTemplates\{0}\", verstr));

            this.RootDirectory = Path.GetFullPath(rootDir);
            this.SourceRoot    = Path.Combine(rootDir, @"sources\");
            this.BaseIntermediateOutputPath = Path.Combine(rootDir, @"baseintout\");
            this.OutputPath  = Path.Combine(rootDir, @"output\");
            this.Dte         = dte;
            this.ActivityLog = activityLogger;
        }