Ejemplo n.º 1
0
        private bool RunCustomTool(ProjectItem item, VSProjectItem vsItem, string customTool, OutputWindowHelper outHelper)
        {
            bool flag  = true;
            bool flag2 = false;

            try
            {
                string text1 = (string)item.Properties.Item("FullPath").Value;
            }
            catch (ArgumentException)
            {
                flag = false;
                outHelper.AddMessage(string.Format(Resources.SkippingNoPath, new object[] { item.Name }));
            }
            if ((flag && (item.ProjectItems != null)) && (item.ProjectItems.Count > 0))
            {
                foreach (ProjectItem item2 in item.ProjectItems)
                {
                    string str = "";
                    try
                    {
                        str = (string)item2.Properties.Item("FullPath").Value;
                    }
                    catch (ArgumentException)
                    {
                        flag = false;
                        outHelper.AddMessage(string.Format(Resources.SkippingNoPath, new object[] { item2.Name }));
                    }
                    if ((!string.IsNullOrEmpty(str) && !_dte.SourceControl.IsItemUnderSCC(str)) && (File.Exists(str) && ((File.GetAttributes(str) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)))
                    {
                        flag = false;
                        outHelper.AddMessage(string.Format(Resources.SkippingReadOnly, new object[] { str }));
                    }
                }
            }
            if (flag)
            {
                outHelper.AddMessage(string.Format(Resources.RunLine, new object[] { customTool, item.Name }));
                try
                {
                    vsItem.RunCustomTool();
                    outHelper.Add(Resources.LineSucceeded);
                }
                catch
                {
                    outHelper.Add(Resources.LineFailed);
                    flag2 = true;
                }
            }
            return(flag2);
        }
Ejemplo n.º 2
0
        void OnTransformSelectedExec(object sender, EventArgs e)
        {
            this.SaveAllDocumentsBeforeBuild();

            _dte.ExecuteCommand("View.Output", "");
            OutputWindowHelper outHelper = new OutputWindowHelper(_dte);
            List <ProjectItem> toProcess = new List <ProjectItem>();

            //Get items to be transformed.
            Project selectedProject = ToDteProject(GetSelectedProject(_serviceProvider));

            FindProjectItems(selectedProject, toProcess);
            outHelper.Clear();
            outHelper.AddMessage(string.Format(Resources.StartCodeGen, selectedProject.Name));
            outHelper.AddMessage(Resources.Seperator);

            uint         pdwCookie = 0;
            uint         count     = (uint)toProcess.Count;
            IVsStatusbar service   = _serviceProvider.GetService(typeof(IVsStatusbar)) as IVsStatusbar;

            if (service != null)
            {
                service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, 0, count);
            }

            uint complete  = 1;
            bool errorFlag = false;

            foreach (ProjectItem item in toProcess)
            {
                Application.DoEvents();
                VSProjectItem vsItem = item.Object as VSProjectItem;
                if (vsItem != null)
                {
                    errorFlag |= this.RunCustomTool(item, vsItem, GetCustomTool(item), outHelper);
                }
                if (service != null)
                {
                    service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, complete, count);
                }
                complete++;
                Application.DoEvents();
            }

            outHelper.AddMessage(Resources.Seperator);
            outHelper.AddMessage(Resources.EndCodeGen);
            if (service != null)
            {
                service.Progress(ref pdwCookie, 0, string.Empty, count, count);
            }
        }
 private bool RunCustomTool(ProjectItem item, VSProjectItem vsItem, string customTool, OutputWindowHelper outHelper)
 {
     bool flag = true;
     bool flag2 = false;
     try
     {
         string text1 = (string)item.Properties.Item("FullPath").Value;
     }
     catch (ArgumentException)
     {
         flag = false;
         outHelper.AddMessage(string.Format(Resources.SkippingNoPath, new object[] { item.Name }));
     }
     if ((flag && (item.ProjectItems != null)) && (item.ProjectItems.Count > 0))
     {
         foreach (ProjectItem item2 in item.ProjectItems)
         {
             string str = "";
             try
             {
                 str = (string)item2.Properties.Item("FullPath").Value;
             }
             catch (ArgumentException)
             {
                 flag = false;
                 outHelper.AddMessage(string.Format(Resources.SkippingNoPath, new object[] { item2.Name }));
             }
             if ((!string.IsNullOrEmpty(str) && !_dte.SourceControl.IsItemUnderSCC(str)) && (File.Exists(str) && ((File.GetAttributes(str) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)))
             {
                 flag = false;
                 outHelper.AddMessage(string.Format(Resources.SkippingReadOnly, new object[] { str }));
             }
         }
     }
     if (flag)
     {
         outHelper.AddMessage(string.Format(Resources.RunLine, new object[] { customTool, item.Name }));
         try
         {
             vsItem.RunCustomTool();
             outHelper.Add(Resources.LineSucceeded);
         }
         catch
         {
             outHelper.Add(Resources.LineFailed);
             flag2 = true;
         }
     }
     return flag2;
 }
        void OnTransformSelectedExec(object sender, EventArgs e)
        {
            this.SaveAllDocumentsBeforeBuild();

            _dte.ExecuteCommand("View.Output", "");
            OutputWindowHelper outHelper = new OutputWindowHelper(_dte);
            List<ProjectItem> toProcess = new List<ProjectItem>();

            //Get items to be transformed.
            Project selectedProject = ToDteProject(GetSelectedProject(_serviceProvider));
            FindProjectItems(selectedProject, toProcess);
            outHelper.Clear();
            outHelper.AddMessage(string.Format(Resources.StartCodeGen, selectedProject.Name));
            outHelper.AddMessage(Resources.Seperator);

            uint pdwCookie = 0;
            uint count = (uint)toProcess.Count;
            IVsStatusbar service = _serviceProvider.GetService(typeof(IVsStatusbar)) as IVsStatusbar;
            if (service != null)
            {
                service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, 0, count);
            }

            uint complete = 1;
            bool errorFlag = false;
            foreach (ProjectItem item in toProcess)
            {
                Application.DoEvents();
                VSProjectItem vsItem = item.Object as VSProjectItem;
                if (vsItem != null)
                {
                    errorFlag |= this.RunCustomTool(item, vsItem, GetCustomTool(item), outHelper);
                }
                if (service != null)
                {
                    service.Progress(ref pdwCookie, 1, Resources.TextTemplatingStatusBarLabel, complete, count);
                }
                complete++;
                Application.DoEvents();
            }

            outHelper.AddMessage(Resources.Seperator);
            outHelper.AddMessage(Resources.EndCodeGen);
            if (service != null)
            {
                service.Progress(ref pdwCookie, 0, string.Empty, count, count);
            }
        }