Exemplo n.º 1
0
        public override IEnumerable <INodeFactory> GetNodeChildren(IContext context)
        {
            foreach (ProjectItem item in _project.ProjectItems)
            {
                yield return(ProjectNodeFactory.Create(item));
            }

            var vsproj = _project.Object as VSLangProj.VSProject;

            if (null != vsproj)
            {
                yield return(new ReferenceCollectionNodeFactory(vsproj.References));
            }

            if (null != _project.Properties)
            {
                yield return(new PropertyCollectionNodeFactory("ProjectProperties", _project.Properties));
            }

            //if (null != _project.CodeModel)
            //{
            //    yield return new ProjectCodeModelNodeFactory(_project.CodeModel);
            //}

            if (null != _project.ConfigurationManager)
            {
                yield return(new ConfigurationsCollectionNodeFactory(_project));
            }
        }
        public override IEnumerable <INodeFactory> GetNodeChildren(IContext context)
        {
            List <INodeFactory> factories = new List <INodeFactory>();

            if (null != _item.ProjectItems)
            {
                foreach (ProjectItem item in _item.ProjectItems)
                {
                    factories.Add(ProjectNodeFactory.Create(item));
                }
            }

            if (PathTopologyVersions.SupportsProjectItemCodeModel(context))
            {
                if (null != _item.FileCodeModel)
                {
                    factories.Add(new FileCodeModelNodeFactory(_item.FileCodeModel));
                }
            }

            if (null != _item.Properties)
            {
                factories.Add(new PropertyCollectionNodeFactory("ItemProperties", _item.Properties));
            }

            return(factories);
        }
Exemplo n.º 3
0
        private Project ResolveProject(IContext context, string projectName)
        {
            Project project     = null;
            var     nodeFactory = new SolutionProjectsNodeFactory(_references.DTE as DTE2);

            project = nodeFactory.ResolveProjectFromName(projectName);
            if (null != project)
            {
                return(project);
            }

            ProjectNodeFactory projectNodeFactory =
                context.ResolvePath(projectName) as ProjectNodeFactory;

            if (null != projectNodeFactory)
            {
                project = projectNodeFactory.Project;
            }

            return(project);
        }
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var p = context.DynamicParameters as NewItemDynamicParameters ?? new NewItemDynamicParameters();

            Solution2 sln = _dte.Solution as Solution2;
            Project item = null;
            Events2 events2 = _dte.Events as Events2;
            var callback = (_dispSolutionEvents_ProjectAddedEventHandler) ((a) => item = a);
            events2.SolutionEvents.ProjectAdded += callback;

            try
            {
                if (!String.IsNullOrEmpty(itemTypeName))
                {
                    if ("folder" == itemTypeName.ToLowerInvariant())
                    {
                        sln.AddSolutionFolder(path);
                    }
                    else
                    {
                        if (!itemTypeName.ToLowerInvariant().EndsWith(".zip"))
                        {
                            itemTypeName += ".zip";
                        }
                        if (String.IsNullOrEmpty(p.Language))
                        {
                            p.Language = "csharp";
                        }

                        var projectName = Path.GetFileNameWithoutExtension(path);

                        var destinationPath = Path.Combine(
                            Path.GetDirectoryName(sln.FullName),
                            projectName
                            );
                        var projectFileName = path;
                        /*if (String.IsNullOrEmpty(Path.GetExtension(path)))
                        {
                            projectFileName += GetProjectFileExtension(p.Language);
                        }*/

                        var t = sln.GetProjectTemplate(itemTypeName, p.Language);
                        _dte.Solution.AddFromTemplate(t, destinationPath, projectFileName, false);
                    }
                }
                else if (!String.IsNullOrEmpty(p.ItemFilePath))
                {
                    sln.AddFromFile(p.ItemFilePath, false);
                }
            }
            finally
            {
                events2.SolutionEvents.ProjectAdded -= callback;
            }
            if (null == item)
            {
                return null;
            }

            var factory = new ProjectNodeFactory(item);
            return factory.GetNodeValue();
        }
Exemplo n.º 5
0
        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            var p = context.DynamicParameters as NewItemDynamicParameters ?? new NewItemDynamicParameters();

            Solution2 sln      = _dte.Solution as Solution2;
            Project   item     = null;
            Events2   events2  = _dte.Events as Events2;
            var       callback = (_dispSolutionEvents_ProjectAddedEventHandler)((a) => item = a);

            events2.SolutionEvents.ProjectAdded += callback;

            try
            {
                if (!String.IsNullOrEmpty(itemTypeName))
                {
                    if ("folder" == itemTypeName.ToLowerInvariant())
                    {
                        sln.AddSolutionFolder(path);
                    }
                    else
                    {
                        if (!itemTypeName.ToLowerInvariant().EndsWith(".zip"))
                        {
                            itemTypeName += ".zip";
                        }
                        if (String.IsNullOrEmpty(p.Language))
                        {
                            p.Language = "csharp";
                        }

                        var projectName = Path.GetFileNameWithoutExtension(path);

                        var destinationPath = Path.Combine(
                            Path.GetDirectoryName(sln.FullName),
                            projectName
                            );
                        var projectFileName = path;

                        /*if (String.IsNullOrEmpty(Path.GetExtension(path)))
                         * {
                         *  projectFileName += GetProjectFileExtension(p.Language);
                         * }*/

                        var t = sln.GetProjectTemplate(itemTypeName, p.Language);
                        _dte.Solution.AddFromTemplate(t, destinationPath, projectFileName, false);
                    }
                }
                else if (!String.IsNullOrEmpty(p.ItemFilePath))
                {
                    sln.AddFromFile(p.ItemFilePath, false);
                }
            }
            finally
            {
                events2.SolutionEvents.ProjectAdded -= callback;
            }
            if (null == item)
            {
                return(null);
            }

            var factory = new ProjectNodeFactory(item);

            return(factory.GetNodeValue());
        }