public static IPathNode NewItem(Project project, ProjectItems items, IContext context, string path, string itemTypeName, object newItemValue)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }
            if (null == project)
            {
                throw new ArgumentNullException("project");
            }

            var p = context.DynamicParameters as NewItemDynamicParameters;

            DTE2        dte      = project.DTE as DTE2;
            Solution2   sln      = dte.Solution as Solution2;
            ProjectItem item     = null;
            Events2     events2  = dte.Events as Events2;
            var         callback = (_dispProjectItemsEvents_ItemAddedEventHandler)((a) => item = a);

            events2.ProjectItemsEvents.ItemAdded += callback;
            try
            {
                if (!String.IsNullOrEmpty(itemTypeName))
                {
                    AddFromItemTypeName(project, items, path, itemTypeName, p, sln);
                }
                else if (!String.IsNullOrEmpty(p.ItemFilePath))
                {
                    AddFromItemFilePath(project, items, p);
                }
                else if (!String.IsNullOrEmpty(p.ProjectFilePath))
                {
                    AddFromProjectFilePath(project, items, p);
                }
            }
            finally
            {
                events2.ProjectItemsEvents.ItemAdded -= callback;
            }
            if (null == item)
            {
                return(null);
            }
            var factory = ProjectItemNodeFactory.Create(item);

            return(factory.GetNodeValue());
        }
        internal static INodeFactory Create(object item)
        {
            if (item is Project)
            {
                return(new ProjectNodeFactory(item as Project));
            }
            var projectItem = item as ProjectItem;

            System.Diagnostics.Debug.Assert(null != projectItem);

            if (null != projectItem.SubProject)
            {
                return(new ProjectNodeFactory(projectItem.SubProject));
            }

            return(ProjectItemNodeFactory.Create(projectItem));
        }