示例#1
0
        /// <summary>
        /// Opens the specified filename from the specified project name.
        /// </summary>
        public EditorWindow OpenItem(string project, params string[] path)
        {
            foreach (EnvDTE.Project proj in VSTestContext.DTE.Solution.Projects)
            {
                if (proj.Name == project)
                {
                    var items = proj.ProjectItems;
                    EnvDTE.ProjectItem item = null;
                    foreach (var itemName in path)
                    {
                        item  = items.Item(itemName);
                        items = item.ProjectItems;
                    }
                    Assert.IsNotNull(item);
                    var window = item.Open();
                    window.Activate();
                    return(App.GetDocument(item.Document.FullName));
                }
            }

            throw new InvalidOperationException(
                      String.Format(
                          "Failed to find {0} item in project {1}",
                          String.Join("\\", path),
                          project
                          )
                      );
        }