当前位置: 首页>>代码示例>>C#>>正文


C# Solution.FindProjectItem方法代码示例

本文整理汇总了C#中Solution.FindProjectItem方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.FindProjectItem方法的具体用法?C# Solution.FindProjectItem怎么用?C# Solution.FindProjectItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solution的用法示例。


在下文中一共展示了Solution.FindProjectItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddToSolution

        /// <summary>
        /// Adds a class file to the relevant visual studio solution
        /// </summary>
        /// <param name="sln">The solution to add the file to</param>
        /// <param name="featureFile">The feature file path that the class file is for.</param>
        /// <param name="classFile">The class file to be added</param>
        /// <returns>true if the class was added succesfully</returns>
        public bool AddToSolution(Solution sln, string featureFile, string classFile)
        {
            //Locate feature file in solution
            ProjectItem prjItem = sln.FindProjectItem(featureFile);
            if (prjItem == null)
                return false;

            //Add the class file into the same project that conatins the feature file.
            prjItem.ContainingProject.ProjectItems.AddFromFile(classFile);
            return true;
        }
开发者ID:pmchugh,项目名称:SpecFlow,代码行数:18,代码来源:FileHandler.cs

示例2: Initialize

		/////////////////////////////////////////////////////////////////////////////

		protected void Initialize( string inputFilePath )
		{
			// ******
			if( null == errListProvider ) {
				//
				// custom tool FAILS if we try to do this in the ctor
				//
				errListProvider = new ErrorListProvider( GlobalServiceProvider );
			}
	
			// ******
			solution = Dte.Solution;
			if( null == solution ) {
				return;
			}

			// ******
			templateItem = solution.FindProjectItem( inputFilePath );
			templateConfigMgr = templateItem.ConfigurationManager;
			templateProject = templateItem.ContainingProject;

			//IEnumerable<Project> projects = GetAllProjects( solution );

			// ******
			//
			// is always null - this is references elsewhere (null is ok)
			//
			projConfig = templateProject.ConfigurationManager.ActiveConfiguration;
		}
开发者ID:jmclain,项目名称:Nmp,代码行数:31,代码来源:NmpRunner.cs

示例3: TryGetProjectItem

        static bool TryGetProjectItem(Solution solution, string path, out ProjectItem item)
        {
            item = null;

            if (solution != null)
                item = solution.FindProjectItem(path);

            // if we found project item, but don't have project items, attempt to find
            // item recursively
            if (item != null && item.ProjectItems == null)
                item = FindProjectItemRecursive(solution, path);

            return item != null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:14,代码来源:InteropHelper.cs

示例4: UpdateOutputFiles

        /// <summary>
        /// Saves content accumulated by this transformation to the output files.
        /// </summary>
        /// <param name="outputFiles">
        /// <see cref="OutputFile"/>s that need to be added to the <paramref name="solution"/>.
        /// </param>
        /// <param name="solution">
        /// Current Visual Studio <see cref="Solution"/>.
        /// </param>
        /// <param name="projects">
        /// All <see cref="Project"/>s in the current <paramref name="solution"/>.
        /// </param>
        /// <param name="template">
        /// A <see cref="ProjectItem"/> that represents T4 template being transformed.
        /// </param>
        /// <remarks>
        /// Note that this method currently cannot distinguish between files that are
        /// already in a Database project and files that are simply displayed with 
        /// "Show All Files" option. Database project model makes these items appear 
        /// as if they were included in the project.
        /// </remarks>
        private static void UpdateOutputFiles(IEnumerable<OutputFile> outputFiles, Solution solution, IEnumerable<Project> projects, ProjectItem template)
        {
            foreach (OutputFile output in outputFiles)
            {
                UpdateOutputFile(output); // Save the output file before we can add it to the solution

                ProjectItem outputItem = solution.FindProjectItem(output.File);
                ProjectItems collection = FindProjectItemCollection(output, projects, template);

                if (outputItem == null)
                {
                    // If output file has not been added to the solution
                    outputItem = collection.AddFromFile(output.File);
                }
                else if (!Same(outputItem.Collection, collection))
                {
                    // If the output file moved from one collection to another
                    string backupFile = output.File + ".bak";
                    File.Move(output.File, backupFile); // Prevent unnecessary source control operations
                    outputItem.Delete(); // Remove doesn't work on "DependentUpon" items
                    File.Move(backupFile, output.File);

                    outputItem = collection.AddFromFile(output.File);
                }

                SetProjectItemProperties(outputItem, output);
                SetProjectItemBuildProperties(outputItem, output);
                AddProjectItemReferences(outputItem, output);
            }
        }
开发者ID:jradxl,项目名称:T4Toolbox-V10-Revised,代码行数:51,代码来源:OutputProcessor.cs

示例5: DeleteOldOutputs

        /// <summary>
        /// Deletes output files that were not generated by the current session.
        /// </summary>
        /// <param name="outputFiles">
        /// A read-only collection of <see cref="OutputFile"/> objects.
        /// </param>
        /// <param name="solution">
        /// Current Visual Studio <see cref="Solution"/>.
        /// </param>
        /// <param name="template">
        /// A <see cref="ProjectItem"/> that represents T4 template being transformed.
        /// </param>
        private static void DeleteOldOutputs(IEnumerable<OutputFile> outputFiles, Solution solution, ProjectItem template)
        {
            // If previous transformation produced a log of generated ouptut files
            string logFile = GetLogFileName();
            if (File.Exists(logFile))
            {
                // Delete all files recorded in the log that were not regenerated
                foreach (string line in File.ReadAllLines(logFile))
                {
                    string relativePath = line.Trim();

                    // Skip blank lines
                    if (relativePath.Length == 0)
                    {
                        continue;
                    }

                    // Skip comments
                    if (relativePath.StartsWith("//", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    string absolutePath = Path.GetFullPath(relativePath);

                    // Skip the file if it was regenerated during current transformation
                    if (outputFiles.Any(output => OutputInfo.SamePath(output.File, absolutePath)))
                    {
                        continue;
                    }

                    // The file wasn't regenerated, delete it from the solution, source control and file storage
                    ProjectItem projectItem = solution.FindProjectItem(absolutePath);
                    if (projectItem != null)
                    {
                        DeleteProjectItem(projectItem);
                    }
                }
            }

            // Also delete all project items nested under template if they weren't regenerated
            string templateFileName = Path.GetFileNameWithoutExtension(Host.TemplateFile);
            foreach (ProjectItem childProjectItem in template.ProjectItems)
            {
                // Skip the file if it has the same name as the template file. This will prevent constant
                // deletion and adding of the main output file to the project, which is slow and may require
                // the user to check the file out unnecessarily.
                if (templateFileName == Path.GetFileNameWithoutExtension(childProjectItem.Name))
                {
                    continue;
                }

                // If the file wan't regenerated, delete it from the the solution, source control and file storage
                if (!outputFiles.Any(o => OutputInfo.SamePath(o.File, childProjectItem.get_FileNames(1))))
                {
                    childProjectItem.Delete();
                }
            }
        }
开发者ID:jradxl,项目名称:T4Toolbox-V10-Revised,代码行数:71,代码来源:OutputProcessor.cs


注:本文中的Solution.FindProjectItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。