Exemple #1
0
        VSLangProj.Reference VSLangProj.References.AddProject(EnvDTE.Project pProject)
        {
            MockEnvDTEProject project = (MockEnvDTEProject)pProject;

            if (!children.Contains(project.Hierarchy.FileName))
            {
                children.Add(project.Hierarchy.FileName);
            }
            return(null);
        }
		public MockVSHierarchy(int childrenSize, string name, Guid guid, MockVSHierarchy parent)
		{
			if ( parent==null && MockVsSolution.Solution != null && MockVsSolution.Solution.Root != null)
			{
				this.parent = MockVsSolution.Solution.Root;
			}
			else
			{
				this.parent = parent;
			}
			this.guid = guid;
			this.subProjects = new List<MockVSHierarchy>();
			this.fileName = name;
			this.children = new List<string>();
			AddChildren(childrenSize);
            if (guid != Guid.Empty &&
                !Directory.Exists(fileName))
            {
                this.project = new Microsoft.Build.Evaluation.Project();  //Microsoft.Build.BuildEngine.Engine.GlobalEngine.CreateNewProject(); 
                string fullPath;
                if (!visitedFiles.TryGetValue(guid, out fullPath))
                {
                    try
                    {
                        this.project.Save(fileName);
                    }
                    catch(InvalidOperationException)
                    {
                        // rename to a random value
                        fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".project");
                        this.project = new Microsoft.Build.Evaluation.Project();
                        this.project.Save(fileName);
                    }
                    fullPath = this.project.FullPath;
                    visitedFiles.GetOrAdd(guid, fullPath);
                 }
                fileName = fullPath;
            }

			externalObject = new MockEnvDTEProject(this);
		}