/// <summary>
        /// Constructor to create a new MSBuild.ProjectItem and add it to the project
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        internal CogaenEditProjectElement(CogaenEditProject project, string itemPath, string itemType)
        {
            if(project == null)
            {
                throw new ArgumentNullException("project");
            }

            if(String.IsNullOrEmpty(itemPath))
            {
                throw new ArgumentException("Parameter cannot be null or Empty", "itemPath");
            }

            if(String.IsNullOrEmpty(itemType))
            {
                throw new ArgumentException("Parameter cannot be null or Empty", "itemType");
            }

            this.itemProject = project;

            // create and add the item to the project

            //this.item = project.BuildProject.AddItem(itemType, Microsoft.Build.Evaluation.ProjectCollection.Escape(itemPath))[0];
            //this.itemProject.SetProjectFileDirty(true);
            this.RefreshProperties();
        }
        public int CreateProject(string pszFilename, string pszLocation, string pszName, uint grfCreateFlags, ref Guid iidProject, out IntPtr ppvProject, out int pfCanceled)
        {
            //throw new NotImplementedException();
            pfCanceled = 0;
            try
            {
                this.buildProject = Utilities.ReinitializeMsBuildProject(this.buildEngine, pszFilename, this.buildProject);

                CogaenEditProject project = new CogaenEditProject(this.Package, (IOleServiceProvider)((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider)), this.buildProject);
                project.BuildEngine = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection;

                project.Load(pszFilename, pszLocation, pszName, grfCreateFlags, ref iidProject, out pfCanceled);
                ppvProject = Marshal.GetIUnknownForObject(project);

            }
            catch(Exception e)
            {
                pfCanceled = 1;
                ppvProject = IntPtr.Zero;
            }
            return VSConstants.S_OK;
        }
        /// <summary>
        /// Constructor to Wrap an existing MSBuild.ProjectItem
        /// Only have internal constructors as the only one who should be creating
        /// such object is the project itself (see Project.CreateFileNode()).
        /// </summary>
        /// <param name="project">Project that owns this item</param>
        /// <param name="existingItem">an MSBuild.ProjectItem; can be null if virtualFolder is true</param>
        /// <param name="virtualFolder">Is this item virtual (such as reference folder)</param>
        internal CogaenEditProjectElement(CogaenEditProject project, MSBuild.ProjectItem existingItem, bool virtualFolder)
        {
            if(project == null)
                throw new ArgumentNullException("project");
            if(!virtualFolder && existingItem == null)
                throw new ArgumentNullException("existingItem");

            // Keep a reference to project and item
            this.itemProject = project;
            this.item = existingItem;
            this.isVirtual = virtualFolder;

            if(this.isVirtual)
                this.virtualProperties = new Dictionary<string, string>();
        }