Exemplo n.º 1
0
        /// <summary>
        /// Parses the frame XML.
        /// </summary>
        /// <param name="frameXmlDeclarationParser">The frame XML declaration parser.</param>
        /// <param name="frameXmlFile">The frame XML file.</param>
        private void ParseFrameXml(FrameXmlDeclarationParser frameXmlDeclarationParser, string frameXmlFile)
        {
            // Get the running document table service
            var rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            IVsHierarchy hierarchy;
            IntPtr docData;
            uint itemid, dwCookie;

            // Try to retrieve current content through the running document table
            ErrorHandler.ThrowOnFailure(rdt.FindAndLockDocument(0, frameXmlFile, out hierarchy,
                                                                                       out itemid, out docData,
                                                                                       out dwCookie));

            // Check if we got a docdata
            if (docData != IntPtr.Zero)
            {
                // Query the docdata for IVsTextLines
                object dataObject = Marshal.GetObjectForIUnknown(docData);
                if (dataObject != null && dataObject is IVsTextLines)
                {
                    var textLines = (IVsTextLines)dataObject;

                    // Get the contents of the file
                    string text = GetText(textLines);

                    // Add the frame XML
                    frameXmlDeclarationParser.AddFrameXmlText(text);
                }
            }
            else
            {
                // Could not get docdata, just add file
                frameXmlDeclarationParser.AddFrameXml(frameXmlFile);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the frame XML declarations.
        /// </summary>
        /// <param name="frameXmlFile">The frame XML file.</param>
        private void AddFrameXmlDeclarations(string frameXmlFile)
        {
            frameXmlDeclarationProviders[frameXmlFile] = new TableDeclarationProvider();

            FrameXmlDeclarationParser frameXmlDeclarationParser =
                new FrameXmlDeclarationParser(frameXmlDeclarationProviders[frameXmlFile]);
            ParseFrameXml(frameXmlDeclarationParser, frameXmlFile);
        }