Exemple #1
0
 internal ReaderImplSub( ReaderImpl rootReader, ReaderBase parent )
     : base(rootReader)
 {
     Parent = parent;
     _jail = Root.CreateJail();
     Root.Current = this;
 }
Exemple #2
0
        public IStructuredReader Restore(IServiceProvider baseServiceProvider)
        {
            XmlReader  r      = new XmlTextReader(_skippedFragment, XmlNodeType.Element, _xmlContext);
            ReaderImpl reader = new ReaderImpl(r, baseServiceProvider, _storageVersion, true);

            return(reader);
        }
Exemple #3
0
 internal ReaderImplSub(ReaderImpl rootReader, ReaderBase parent)
     : base(rootReader)
 {
     Parent       = parent;
     _jail        = Root.CreateJail();
     Root.Current = this;
 }
Exemple #4
0
 public SubReaderJail(ReaderImpl holder)
 {
     _previous         = holder._xmlReader;
     holder._xmlReader = _previous.ReadSubtree();
     // Moves the reader on the current node.
     holder._xmlReader.Read();
     _holder = holder;
 }
Exemple #5
0
 public void Dispose()
 {
     if (_root != null)
     {
         if (_deserializationActions != null)
         {
             _deserializationActions.RunOnce();
         }
         OnDispose();
         _root = null;
     }
 }
        /// <summary>
        /// Creates a simple (full xml based) <see cref="IStructuredReader"/> instance.
        /// The inner stream will be closed whenever the reader will be disposed.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="serviceProvider">The <see cref="IServiceProvider"/> to use.</param>
        /// <param name="throwErrorOnMissingFile">True to throw an exception when the <paramref name="stream"/> parameter is null.</param>
        /// <returns>A reader bound to the <paramref name="stream"/> or null.</returns>
        static public IStructuredReader CreateReader(Stream stream, IServiceProvider serviceProvider, bool throwErrorOnMissingFile)
        {
            if (stream == null)
            {
                if (throwErrorOnMissingFile)
                {
                    throw new CKException(R.FileNotFound);
                }
                else
                {
                    return(null);
                }
            }
            XmlReader r = null;

            try
            {
                r = XmlReader.Create(stream, new XmlReaderSettings()
                {
                    CloseInput     = true,
                    IgnoreComments = true,
                    IgnoreProcessingInstructions = true,
                    IgnoreWhitespace             = true,
                    DtdProcessing  = DtdProcessing.Prohibit,
                    ValidationType = ValidationType.None
                });
            }
            catch (Exception ex)
            {
                if (r != null)
                {
                    r.Close();
                }
                throw new CKException(R.InvalidFileManifest, ex);
            }
            ReaderImpl rw = new ReaderImpl(r, serviceProvider, true);

            if (rw.StorageVersion == null)
            {
                rw.Dispose();
                throw new CKException(R.InvalidFileManifestVersion);
            }
            return(rw);
        }
Exemple #7
0
 protected ReaderBase( ReaderImpl root )
 {
     _root = root ?? (ReaderImpl)this;
 }
Exemple #8
0
 public void Dispose()
 {
     if( _root != null )
     {
         if( _deserializationActions != null ) _deserializationActions.RunOnce();
         OnDispose();
         _root = null;
     }
 }
Exemple #9
0
 public IStructuredReader Restore( IServiceProvider baseServiceProvider )
 {
     XmlReader r = new XmlTextReader( _skippedFragment, XmlNodeType.Element, _xmlContext );
     ReaderImpl reader = new ReaderImpl( r, baseServiceProvider, _storageVersion, true );
     return reader;
 }
Exemple #10
0
 protected ReaderBase(ReaderImpl root)
 {
     _root = root ?? (ReaderImpl)this;
 }
Exemple #11
0
 public SubReaderJail( ReaderImpl holder )
 {
     _previous = holder._xmlReader;
     holder._xmlReader = _previous.ReadSubtree();
     // Moves the reader on the current node.
     holder._xmlReader.Read();
     _holder = holder;
 }
 /// <summary>
 /// Creates a simple (full xml based) <see cref="IStructuredReader"/> instance.
 /// The inner stream will be closed whenever the reader will be disposed.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="serviceProvider">The <see cref="IServiceProvider"/> to use.</param>
 /// <param name="throwErrorOnMissingFile">True to throw an exception when the <paramref name="stream"/> parameter is null.</param>
 /// <returns>A reader bound to the <paramref name="stream"/> or null.</returns>
 public static IStructuredReader CreateReader( Stream stream, IServiceProvider serviceProvider, bool throwErrorOnMissingFile )
 {
     if( stream == null )
     {
         if( throwErrorOnMissingFile )
             throw new CKException( R.FileNotFound );
         else
             return null;
     }
     XmlReader r = null;
     try
     {
         r = XmlReader.Create( stream, new XmlReaderSettings()
         {
             CloseInput = true,
             IgnoreComments = true,
             IgnoreProcessingInstructions = true,
             IgnoreWhitespace = true,
             DtdProcessing = DtdProcessing.Prohibit,
             ValidationType = ValidationType.None
         } );
     }
     catch( Exception ex )
     {
         if( r != null ) r.Close();
         throw new CKException( R.InvalidFileManifest, ex );
     }
     ReaderImpl rw = new ReaderImpl( r, serviceProvider, true );
     if( rw.StorageVersion == null )
     {
         rw.Dispose();
         throw new CKException( R.InvalidFileManifestVersion );
     }
     return rw;
 }