public void Render(IItem item, Dictionary <string, object> output)
        {
            output["type"] = item.GetType().Name;

            if (item.GetType().CanBeCastTo <EmailLog>())
            {
                var emailLog = (EmailLog)item;
                output["header"] = emailLog.Header;
                output["items"]  = Render(emailLog.Items);
                return;
            }

            if (item.GetType().CanBeCastTo <EmailHeader>())
            {
                output["header"] = item.As <EmailHeader>();
                return;
            }

            if (item.GetType().CanBeCastTo <BlockQuote>())
            {
                output["lines"] = item.As <BlockQuote>().Lines;
                return;
            }

            if (item.GetType().CanBeCastTo <OriginalMessage>())
            {
                var original = (OriginalMessage)item;
                output["header"] = original.Header;
                output["items"]  = Render(original.Items);
                return;
            }

            item.GetType().GetProperties().Each(_ =>
            {
                output.Add(_.Name.Substring(0, 1).ToLower() + _.Name.Substring(1), _.GetValue(item, null));
            });
        }
        public static void Open(this IItem item)
        {
            Guard.NotNull(() => item, item);

            var projectItem = item.As <EnvDTE.ProjectItem>();

            if (projectItem != null)
            {
                var window = projectItem.Open(EnvDTE.Constants.vsViewKindPrimary);
                if (window != null)
                {
                    window.Activate();
                }
            }
        }
Beispiel #3
0
        private void ProcessItem(IItem item)
        {
            if (IsValidTarget(item))
            {
                var message = string.Empty;

                if (this.Dte.SourceControl.IsItemUnderSCC(item.PhysicalPath))
                {
                    this.Dte.SourceControl.CheckOutItem(item.PhysicalPath);
                }
                else
                {
                    var attributes = File.GetAttributes(item.PhysicalPath);

                    if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                    {
                        tracer.Info(
                            Resources.TransformTemplatesCommand_TraceReadOnly, item.GetLogicalPath());

                        return;
                    }
                }

                try
                {
                    message = string.Format(CultureInfo.CurrentCulture,
                                            Properties.Resources.TransformTemplatesCommand_TraceSucceded, item.GetLogicalPath(), CustomToolName);

                    var vsProjectItem = item.As <ProjectItem>().Object as VSProjectItem;

                    if (vsProjectItem != null)
                    {
                        vsProjectItem.RunCustomTool();
                    }
                }
                catch (Exception e)
                {
                    message = string.Format(CultureInfo.CurrentCulture,
                                            Properties.Resources.TransformTemplatesCommand_TraceError, item.GetLogicalPath(), e.Message);
                }

                tracer.Info(message);
                this.StatusBar.DisplayMessage(message);
            }
        }
Beispiel #4
0
 public static IItemHistory CreateHistory(this IItem item)
 {
     return item.As<IItemHistory>();
 }
        private void ProcessItem(IItem item)
        {
            if (IsValidTarget(item))
            {
                var message = string.Empty;

                if (this.Dte.SourceControl.IsItemUnderSCC(item.PhysicalPath))
                {
                    this.Dte.SourceControl.CheckOutItem(item.PhysicalPath);
                }
                else
                {
                    var attributes = File.GetAttributes(item.PhysicalPath);

                    if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
                    {
                        tracer.Info(
                            Resources.TransformTemplatesCommand_TraceReadOnly, item.GetLogicalPath());

                        return;
                    }
                }

                try
                {
                    message = string.Format(CultureInfo.CurrentCulture,
                            Properties.Resources.TransformTemplatesCommand_TraceSucceded, item.GetLogicalPath(), CustomToolName);

                    var vsProjectItem = item.As<ProjectItem>().Object as VSProjectItem;

                    if (vsProjectItem != null)
                    {
                        vsProjectItem.RunCustomTool();
                    }
                }
                catch (Exception e)
                {
                    message = string.Format(CultureInfo.CurrentCulture,
                                Properties.Resources.TransformTemplatesCommand_TraceError, item.GetLogicalPath(), e.Message);
                }

                tracer.Info(message);
                this.StatusBar.DisplayMessage(message);
            }
        }
        public static void Delete(this IItem item)
        {
            Guard.NotNull(() => item, item);

            item.As <EnvDTE.ProjectItem>().Delete();
        }
        public static void Save(this IItem item)
        {
            Guard.NotNull(() => item, item);

            item.As <ProjectItem>().Save();
        }