src/Misc/EFTools/DesignXmlCore/Common/RdtManager.cs
/// <summary>
///     Open the file in invisible editor in RDT, and get text buffer from it.
/// </summary>
/// <remarks>
///     This method created for refactoring usage, refactoring will work on all kinds of
///     docdata, not only SqlEditorDocData.  If change this method, please get let LiangZ
///     know.
/// </remarks>
/// <param name="fullPathFileName">File name with full path.</param>
/// <param name="project">the hierarchy for the document</param>
/// <param name="spEditor">The result invisible editor.</param>
/// <param name="textLines">The result text buffer.</param>
/// <returns>True, if the file is opened correctly in invisible editor.</returns>
Open the file in invisible editor in RDT, and get text buffer from it.
Open the file in invisible editor in RDT and get text buffer from it .
public bool TryGetTextLinesAndInvisibleEditor(
            string fullPathFileName, VsShell.IVsProject project, out VsShell.IVsInvisibleEditor spEditor,
            out VsTextMgr.IVsTextLines textLines)
        {
            spEditor = null;
            textLines = null;
            VsShell.IVsInvisibleEditorManager invisibleEditorMgr;
            var ppDocData = IntPtr.Zero;
            bool result;
            var iidIVsTextLines = typeof(VsTextMgr.IVsTextLines).GUID;
            try
            {
                invisibleEditorMgr = _invisibleEditorManager;
                NativeMethods.ThrowOnFailure(
                    invisibleEditorMgr.RegisterInvisibleEditor(
                        fullPathFileName, project, (uint)VsShell._EDITORREGFLAGS.RIEF_ENABLECACHING, null, out spEditor));
                if (spEditor != null)
                {
                    var hr = spEditor.GetDocData(0, ref iidIVsTextLines, out ppDocData);
                    if (hr == VSConstants.S_OK
                        && ppDocData != IntPtr.Zero)
                    {
                        textLines = Marshal.GetTypedObjectForIUnknown(ppDocData, typeof(VsTextMgr.IVsTextLines)) as VsTextMgr.IVsTextLines;
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            finally
            {
                if (ppDocData != IntPtr.Zero)
                {
                    Marshal.Release(ppDocData);
                }
            }
            return result;
        }
public bool TryGetTextLinesAndInvisibleEditor ( string fullPathFileName , VsShell . IVsProject project , out VsShell . IVsInvisibleEditor spEditor , out VsTextMgr . IVsTextLines textLines ) { spEditor = null ; textLines = null ; VsShell . IVsInvisibleEditorManager invisibleEditorMgr ; var ppDocData = IntPtr . Zero ; bool result ; var iidIVsTextLines = typeof ( VsTextMgr . IVsTextLines ) . GUID ; try { invisibleEditorMgr = _invisibleEditorManager ; NativeMethods . ThrowOnFailure ( invisibleEditorMgr . RegisterInvisibleEditor ( fullPathFileName , project , ( uint ) VsShell . _EDITORREGFLAGS . RIEF_ENABLECACHING , null , out spEditor ) ) ; if ( spEditor != null ) { var hr = spEditor . GetDocData ( 0 , ref iidIVsTextLines , out ppDocData ) ; if ( hr == VSConstants . S_OK && ppDocData != IntPtr . Zero ) { textLines = Marshal . GetTypedObjectForIUnknown ( ppDocData , typeof ( VsTextMgr . IVsTextLines ) ) as VsTextMgr . IVsTextLines ; result = true ; } else { result = false ; } } else { result = false ; } } finally { if ( ppDocData != IntPtr . Zero ) { Marshal . Release ( ppDocData ) ; } } return result ; }
Open the file in invisible editor in RDT, and get text buffer from it.
Open the file in invisible editor in RDT and get text buffer from it .
// Need to open this file.  Use the invisible editor manager to do so.
True, if the file is opened correctly in invisible editor.
True if the file is opened correctly in invisible editor .
fullPathFileName
string
File name with full path.
File name with full path .
project
VsShell.IVsProject
the hierarchy for the document
the hierarchy for the document
VsShell.IVsInvisibleEditor
out
VsTextMgr.IVsTextLines
out
spEditor
The result invisible editor.
The result invisible editor .
textLines
The result text buffer.
The result text buffer .
remarks
This method created for refactoring usage, refactoring will work on all kinds of
docdata, not only SqlEditorDocData.  If change this method, please get let LiangZ
know.
This method created for refactoring usage refactoring will work on all kinds of docdata not only SqlEditorDocData . If change this method please get let LiangZ know .