Exemple #1
0
 /// <summary>
 /// Constructor to hydrate the private members
 /// </summary>
 public FxCopLogReader()
 {
     _dispatchTable = new SparseReaderDispatchTable
     {
         { SchemaStrings.ElementFxCopReport, ReadFxCopReport },
         { SchemaStrings.ElementExceptions, ReadExceptions },
         { SchemaStrings.ElementException, ReadException },
         { SchemaStrings.ElementExceptionMessage, ReadExceptionMessage },
         { SchemaStrings.ElementStackTrace, ReadStackTrace },
         { SchemaStrings.ElementInnerType, ReadInnerExceptionType },
         { SchemaStrings.ElementInnerExceptionMessage, ReadInnerExceptionMessage },
         { SchemaStrings.ElementInnerStackTrace, ReadInnerStackTrace },
         { SchemaStrings.ElementRules, ReadRules },
         { SchemaStrings.ElementRule, ReadRule },
         { SchemaStrings.ElementResolution, ReadResolution },
         { SchemaStrings.ElementTargets, ReadTargets },
         { SchemaStrings.ElementTarget, ReadTarget },
         { SchemaStrings.ElementResources, ReadResources },
         { SchemaStrings.ElementResource, ReadResource },
         { SchemaStrings.ElementModules, ReadModules },
         { SchemaStrings.ElementModule, ReadModule },
         { SchemaStrings.ElementNamespaces, ReadNamespaces },
         { SchemaStrings.ElementNamespace, ReadNamespace },
         { SchemaStrings.ElementTypes, ReadTypes },
         { SchemaStrings.ElementType, ReadType },
         { SchemaStrings.ElementMembers, ReadMembers },
         { SchemaStrings.ElementMember, ReadMember },
         { SchemaStrings.ElementMessages, ReadMessages },
         { SchemaStrings.ElementMessage, ReadMessage },
         { SchemaStrings.ElementIssue, ReadIssue },
         { SchemaStrings.ElementItem, ReadItem },
     };
 }
        /// <summary>
        /// Creates a new <see cref="SparseReader"/> pointing to a <see cref="System.IO.Stream"/> rather
        /// than a <see cref="System.Xml.XmlReader"/>.
        /// </summary>
        /// <param name="dispatchTable">The dispatch table used to fire delegates for XML elements on
        /// this instance.</param>
        /// <param name="stream">The stream from which XML shall be retrieved. The SparseReader takes
        /// ownership of this stream and is responsible for destroying it.</param>
        /// <param name="schemaSet">The xml schema to validate the input against</param>
        /// <returns>
        /// A <see cref="SparseReader"/> wrapping the stream <paramref name="stream"/>.
        /// </returns>
        public static SparseReader CreateFromStream(SparseReaderDispatchTable dispatchTable, Stream stream, XmlSchemaSet schemaSet)
        {
            var settings = new XmlReaderSettings
            {
                DtdProcessing = DtdProcessing.Ignore,
                CloseInput    = true,
                Schemas       = schemaSet,
                XmlResolver   = null
            };

            XmlReader xReader = null;

            try
            {
                xReader = XmlReader.Create(stream, settings);
                xReader.MoveToContent();                               // If this throws, we destroy the reader in the finally block below.
                var result = new SparseReader(dispatchTable, xReader); // nothrow
                xReader = null;                                        // Ownership transfered to SparseReader; don't destroy here
                return(result);
            }
            finally
            {
                if (xReader != null)
                {
                    xReader.Dispose();
                }
            }
        }
 /// <summary>
 /// Creates a new <see cref="SparseReader"/> pointing to a <see cref="System.IO.Stream"/> rather
 /// than a <see cref="System.Xml.XmlReader"/>.
 /// </summary>
 /// <param name="dispatchTable">The dispatch table used to fire delegates for XML elements on
 /// this instance.</param>
 /// <param name="stream">The stream from which XML shall be retrieved. The SparseReader takes
 /// ownership of this stream and is responsible for destroying it.</param>
 /// <returns>
 /// A <see cref="SparseReader"/> wrapping the stream <paramref name="stream"/>.
 /// </returns>
 public static SparseReader CreateFromStream(SparseReaderDispatchTable dispatchTable, Stream stream)
 {
     return(CreateFromStream(dispatchTable, stream, null));
 }
 /// <summary>Initializes a new instance of the <see cref="SparseReader"/> class.</summary>
 /// <param name="dispatchTable">The dispatch table used to fire delegates for XML elements on
 /// this instance.</param>
 /// <param name="xmlReader">The reader from which XML shall be retrieved. This SparseReader takes
 /// ownership of this XML reader and destroys it upon destruction.</param>
 public SparseReader(SparseReaderDispatchTable dispatchTable, XmlReader xmlReader)
 {
     _dispatchTable = dispatchTable;
     _xmlReader     = xmlReader;
 }