public ProjectItemRelationship (ProjectItem parentProjectItem, MD.ProjectItem msbuildProjectItem)
		{
			this.ParentProjectItem = parentProjectItem;
			this.MSBuildProjectItem = msbuildProjectItem;
			this.Project = (Project)parentProjectItem.ContainingProject;
			GetRelationship ();
		}
		public References (
			MD.DotNetProject project,
			IExtendedPackageManagementProjectService projectService)
		{
			this.msbuildProject = project;
			this.projectService = projectService;
		}
		bool IsInProjectRootFolder (MD.ProjectFile item)
		{
			if (item.IsLink) {
				return !HasDirectoryInPath (item.Link);
			}
			return !HasDirectoryInPath (item.FilePath);
		}
		global::EnvDTE.ProjectItems CreateProjectItems (MD.ProjectFile projectItem)
		{
			if (projectItem.FilePath.IsDirectory) {
				return new DirectoryProjectItems (this);
			}
			return new FileProjectItems (this);
		}
//		internal static ProjectItem FindByEntity (IProject project, IEntity entity)
//		{
//			if (entity.Region.FileName != null) {
//				return FindByFileName (project, entity.Region.FileName);
//			}
//			return null;
//		}

		internal static ProjectItem FindByFileName (MD.DotNetProject project, string fileName)
		{
//			MD.ProjectFile item = project.FindFile (new FileName (fileName));
//			if (item != null) {
//				return new ProjectItem (new Project (project), item);
//			}
			return null;
		}
		public ProjectItem (Project project, MD.ProjectFile projectItem)
		{
			this.projectItem = projectItem;
			this.containingProject = project;
			this.ProjectItems = CreateProjectItems (projectItem);
			CreateProperties ();
			Kind = GetKindFromFileProjectItemType ();
		}
		ProjectItem ConvertToProjectItem (MD.ProjectItem item)
		{
			var fileItem = item as MD.ProjectFile;
			if ((fileItem != null) && String.IsNullOrEmpty (fileItem.DependsOn)) {
				return ConvertFileToProjectItem (fileItem);
			}
			return null;
		}
		ProjectItem ConvertFileToProjectItem (MD.ProjectFile fileItem)
		{
			if (IsInProjectRootFolder (fileItem)) {
				if (IsDirectory (fileItem)) {
					return CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded (fileItem);
				}
				return new ProjectItem (project, fileItem);
			}
			return ConvertDirectoryToProjectItem (fileItem);
		}
		internal override bool IsChildItem (MD.ProjectItem msbuildProjectItem)
		{
			var fileItem = msbuildProjectItem as MD.ProjectFile;
			if (fileItem == null)
				return false;

			string relativePath = GetPathRelativeToProject (fileItem.FilePath);
			string directory = Path.GetDirectoryName (relativePath);
			if (directory == relativePath) {
				return true;
			}
			return false;
		}
		bool IsDirectory (MD.ProjectFile fileItem)
		{
			return fileItem.FilePath.IsDirectory;
		}
		void AddProjectItemToMSBuildProject (MD.ProjectFile projectItem)
		{
			DotNetProject.AddFile (projectItem);
		}
		ProjectItem ConvertDirectoryToProjectItem (MD.ProjectFile fileItem)
		{
			string relativePath = project.GetRelativePath (fileItem.FilePath);
			string subDirectoryName = GetFirstSubDirectoryName (relativePath);
			if (IsDirectoryInsideProject (subDirectoryName)) {
				string fullPath = project.DotNetProject.BaseDirectory.Combine (subDirectoryName);
				return CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded (subDirectoryName, fullPath);
			}
			return null;
		}
		ProjectItem CreateDirectoryProjectItemIfDirectoryNotAlreadyIncluded (MD.ProjectFile fileItem)
		{
			string directory = fileItem.FilePath;
			if (!IsDirectoryIncludedAlready (directory)) {
				AddIncludedDirectory (directory);
				return new ProjectItem (project, fileItem);
			}
			return null;
		}
		public static bool IsDependentUpon (this MD.ProjectFile projectItem, MD.ProjectFile otherProjectItem)
		{
			return projectItem.DependsOnFile == otherProjectItem;
		}
		bool IsReferenceMatch (MD.ProjectReference reference, string include)
		{
			return String.Equals (reference.Reference, include, StringComparison.InvariantCultureIgnoreCase);
		}
		ProjectItem GetChildProjectItem (MD.ProjectItem msbuildProjectItem)
		{
			ProjectItemRelationship relationship = ProjectItem.GetRelationship (msbuildProjectItem);
			return relationship.GetChild ();
		}
		public Reference3 (Project project, MD.ProjectReference referenceProjectItem)
			: base (project, referenceProjectItem)
		{
		}
		internal virtual ProjectItemRelationship GetRelationship (MD.ProjectItem msbuildProjectItem)
		{
			return new ProjectItemRelationship (this, msbuildProjectItem);
		}
		internal virtual bool IsChildItem (MD.ProjectItem msbuildProjectItem)
		{
			var fileItem = msbuildProjectItem as MD.ProjectFile;
			if (fileItem != null) {
				string directory = fileItem.FilePath.ParentDirectory;
				string relativePath = GetPathRelativeToProject (directory);
				return IsMatchByName (relativePath);
			}
			return false;
		}
		internal void RemoveReference (MD.ProjectReference referenceItem)
		{
			DotNetProject.References.Remove (referenceItem);
		}
		public References (MD.DotNetProject project)
			: this (project, PackageManagementExtendedServices.ProjectService)
		{
		}
		public Reference (Project project, MD.ProjectReference referenceProjectItem)
		{
			this.project = project;
			this.referenceProjectItem = referenceProjectItem;
		}
		public DirectoryProjectItem (Project project, MD.ProjectFile projectItem)
			: base (project, projectItem)
		{
		}