public void RecursiveFindByNameIgnoreCase()
        {
            MockVSHierarchy hierarchy = new MockVSHierarchy();
            MockVsSolution  solution  = new MockVsSolution(hierarchy);
            MockVSHierarchy project1  = new MockVSHierarchy("Project1.project");

            hierarchy.AddProject(project1);
            string child1 = "Child1";

            project1.AddChild(child1);
            MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");

            hierarchy.AddProject(project2);
            string child2 = "ChIlD2.cd";

            project2.AddChild(child2);
            string child3 = "ChildThree3";

            project2.AddChild(child3);
            string child4 = "Child4NotAdded";

            HierarchyNode node = new HierarchyNode(solution);

            Assert.IsNull(node.FindByName(child1));
            Assert.IsNull(node.FindByName(child2));
            Assert.IsNull(node.FindByName(child3));
            Assert.IsNull(node.FindByName(child4));
            Assert.IsNotNull(node.RecursiveFindByName(child1.ToLowerInvariant()));
            Assert.IsNotNull(node.RecursiveFindByName(child2.ToUpperInvariant()));
            Assert.IsNotNull(node.RecursiveFindByName(CodeIdentifier.MakeCamel(child3)));
            Assert.IsNull(node.RecursiveFindByName(child4));
        }
        public void RecursiveFindByName()
        {
            MockVSHierarchy hierarchy = new MockVSHierarchy();
            MockVsSolution  solution  = new MockVsSolution(hierarchy);
            MockVSHierarchy project1  = new MockVSHierarchy("Project1.project");

            hierarchy.AddProject(project1);
            string child1 = "Child1";

            project1.AddChild(child1);
            MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");

            hierarchy.AddProject(project2);
            string child2 = "Child2";

            project2.AddChild(child2);
            string child3 = "Child3";

            project2.AddChild(child3);
            string child4 = "Child4";

            HierarchyNode node = new HierarchyNode(solution);

            Assert.IsNull(node.FindByName(child1));
            Assert.IsNull(node.FindByName(child2));
            Assert.IsNull(node.FindByName(child3));
            Assert.IsNull(node.FindByName(child4));
            Assert.IsNotNull(node.RecursiveFindByName(child1));
            Assert.IsNotNull(node.RecursiveFindByName(child2));
            Assert.IsNotNull(node.RecursiveFindByName(child3));
            Assert.IsNull(node.RecursiveFindByName(child4));
        }
Beispiel #3
0
        /// <summary>
        /// Gets the resource path.
        /// </summary>
        /// <param name="resourceItem">The resource item.</param>
        /// <returns></returns>
        public string GetResourcePath(string resourceItem)
        {
            Guard.ArgumentNotNullOrEmptyString(resourceItem, "resourceItem");

            IVsSolution   solution = GetService <IVsSolution, SVsSolution>();
            HierarchyNode rootNode = new HierarchyNode(solution);
            HierarchyNode file     = rootNode.RecursiveFindByName(resourceItem);

            return(file != null ? file.Path : GetFallbackResourcePath(resourceItem));
        }
Beispiel #4
0
 private HierarchyNode InternalGetOrCreateMappingFile()
 {
     using (HierarchyNode root = new HierarchyNode(VSSolution))
     {
         HierarchyNode found = root.RecursiveFindByName(Helpers.Constants.MappingFile);
         if (found != null)
         {
             return(found);
         }
         using (found = root.FindOrCreateSolutionFolder(Helpers.Constants.SolutionItems))
         {
             return(found != null?found.FindByName(Helpers.Constants.MappingFile) : null);
         }
     }
 }
Beispiel #5
0
        /// <summary>
        /// Gets the xsd full path.
        /// </summary>
        /// <param name="resourceItem">The resource item.</param>
        /// <returns></returns>
        private string GetXsdFullPath(ModelElement mel, string xsdFile)
        {
            IVsSolution solution = GetService <IVsSolution, SVsSolution>(mel);

            using (HierarchyNode rootNode = new HierarchyNode(solution))
                using (HierarchyNode file = rootNode.RecursiveFindByName(xsdFile))
                {
                    if (file != null && File.Exists(file.Path))
                    {
                        return(file.Path);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
        }
		public void RecursiveFindByNameIgnoreCase()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
			hierarchy.AddProject(project1);
			string child1 = "Child1";
			project1.AddChild(child1);
			MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
			hierarchy.AddProject(project2);
			string child2 = "ChIlD2.cd";
			project2.AddChild(child2);
			string child3 = "ChildThree3";
			project2.AddChild(child3);
			string child4 = "Child4NotAdded";

			HierarchyNode node = new HierarchyNode(solution);
			Assert.IsNull(node.FindByName(child1));
			Assert.IsNull(node.FindByName(child2));
			Assert.IsNull(node.FindByName(child3));
			Assert.IsNull(node.FindByName(child4));
			Assert.IsNotNull(node.RecursiveFindByName(child1.ToLowerInvariant()));
			Assert.IsNotNull(node.RecursiveFindByName(child2.ToUpperInvariant()));
			Assert.IsNotNull(node.RecursiveFindByName(CodeIdentifier.MakeCamel(child3)));
			Assert.IsNull(node.RecursiveFindByName(child4));
		}
		public void RecursiveFindByName()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
			hierarchy.AddProject(project1);
			string child1 = "Child1";
			project1.AddChild(child1);
			MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
			hierarchy.AddProject(project2);
			string child2 = "Child2";
			project2.AddChild(child2);
			string child3 = "Child3";
			project2.AddChild(child3);
			string child4 = "Child4";

			HierarchyNode node = new HierarchyNode(solution);
			Assert.IsNull(node.FindByName(child1));
			Assert.IsNull(node.FindByName(child2));
			Assert.IsNull(node.FindByName(child3));
			Assert.IsNull(node.FindByName(child4));
			Assert.IsNotNull(node.RecursiveFindByName(child1));
			Assert.IsNotNull(node.RecursiveFindByName(child2));
			Assert.IsNotNull(node.RecursiveFindByName(child3));
			Assert.IsNull(node.RecursiveFindByName(child4));
		}