Beispiel #1
0
        ///--------------------------------------------------------------------------------------------
        /// <summary>
        ///     Returns the relative path of the project item
        ///
        ///     folder\file.ext
        /// </summary>
        ///--------------------------------------------------------------------------------------------
        internal string ProjRelativePath()
        {
            string projRelativePath = null;

            string rootProjectDir = Root().ProjectDir();

            rootProjectDir = WAUtilities.EnsureTrailingBackSlash(rootProjectDir);
            string fullPath = FullPath();

            if (!string.IsNullOrEmpty(rootProjectDir) && !string.IsNullOrEmpty(fullPath))
            {
                projRelativePath = WAUtilities.MakeRelativePath(fullPath, rootProjectDir);
            }

            return(projRelativePath);
        }
Beispiel #2
0
 ///-------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Creates and loads the document data
 /// (You must Close() it when done)
 /// </summary>
 ///-------------------------------------------------------------------------------------------------------------
 public IVsPersistDocData CreateDocumentData()
 {
     if (IsFile())
     {
         string fullPath = FullPath();
         if (!string.IsNullOrEmpty(fullPath))
         {
             IOleServiceProvider serviceProvider = (IOleServiceProvider)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IOleServiceProvider));
             IVsPersistDocData   docData         = WAUtilities.CreateSitedInstance <IVsPersistDocData>(serviceProvider, typeof(VsTextBufferClass).GUID);
             if (docData != null)
             {
                 int hr = docData.LoadDocData(fullPath);
                 if (ErrorHandler.Succeeded(hr))
                 {
                     return(docData);
                 }
             }
         }
     }
     return(null);
 }