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


C# IVsProject.IsDocumentInProject方法代码示例

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


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

示例1: PreGenerateCode

 /// <summary>
 /// Pres the content of the generate.
 /// </summary>
 /// <param name="vsProject">The vs project.</param>
 /// <param name="inputFileName">The input file path.</param>
 /// <exception cref="System.ApplicationException">
 /// Unable to retrieve Visual Studio ProjectItem
 /// or
 /// Unable to retrieve Visual Studio ProjectItem
 /// </exception>
 protected void PreGenerateCode(IVsProject vsProject, string inputFileName)
 {
     _newFileNames.Clear();
     int iFound;
     uint itemId;
     vsProject.IsDocumentInProject(inputFileName, out iFound, new VSDOCUMENTPRIORITY[1], out itemId);
     if (iFound == 0 || itemId == 0)
         throw new ApplicationException("Unable to retrieve Visual Studio ProjectItem");
     IServiceProvider sp;
     vsProject.GetItemContext(itemId, out sp);
     if (sp == null)
         throw new ApplicationException("Unable to retrieve Visual Studio ProjectItem");
     var item = (new ServiceProvider(sp).GetService(typeof(ProjectItem)) as ProjectItem);
     foreach (string i in this)
     {
         try
         {
             var inputFileName2 = GetFileName(i);
             _newFileNames.Add(inputFileName2);
             var path = Path.Combine(inputFileName.Substring(0, inputFileName.LastIndexOf(Path.DirectorySeparatorChar)), inputFileName2);
             var inputFileContent2 = string.Empty;
             if (File.Exists(path))
                 try { inputFileContent2 = File.ReadAllText(path); }
                 catch (Exception) { inputFileContent2 = string.Empty; }
             var s = File.Create(path);
             try
             {
                 var data = GenerateChildCode(path, inputFileContent2);
                 s.Write(data, 0, data.Length);
                 s.Close();
                 item.ProjectItems.AddFromFile(path);
             }
             catch (Exception)
             {
                 s.Close();
                 if (File.Exists(path))
                     File.Delete(path);
             }
         }
         catch (Exception ex) { throw ex; }
     }
     foreach (ProjectItem childItem in item.ProjectItems)
         if (!(childItem.Name.EndsWith(GetDefaultExtension()) || _newFileNames.Contains(childItem.Name)))
             childItem.Delete();
 }
开发者ID:BclEx,项目名称:BclEx-Extend,代码行数:55,代码来源:BaseCodeMultipleGeneratorWithSite.cs

示例2: GetProjectAndFileInfoForPath

    public static bool GetProjectAndFileInfoForPath(
        IVsProject vsProject, string originalPath, out IVsHierarchy projectHierarchy, out Project project, out uint fileItemId,
        out bool isDocInProject) {
      isDocInProject = false;
      fileItemId = 0;
      projectHierarchy = null;
      project = null;

      var priority = new VSDOCUMENTPRIORITY[1];
      var isDocInProjectInt = 0;

      uint foundItemId = 0;
      var hr = vsProject.IsDocumentInProject(originalPath, out isDocInProjectInt, priority, out foundItemId);
      if (NativeMethods.Succeeded(hr) && isDocInProjectInt == 1) {
        projectHierarchy = vsProject as IVsHierarchy;
        if (projectHierarchy != null) {
          project = GetProject(projectHierarchy);
        }
        fileItemId = foundItemId;
        isDocInProject = true;
      }
      return isDocInProject;
    }
开发者ID:PavelPZ,项目名称:REW,代码行数:23,代码来源:VSHelpers.cs


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