Пример #1
0
 internal ReaderImplSub( ReaderImpl rootReader, ReaderBase parent )
     : base(rootReader)
 {
     Parent = parent;
     _jail = Root.CreateJail();
     Root.Current = this;
 }
Пример #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);
        }
Пример #3
0
 internal ReaderImplSub(ReaderImpl rootReader, ReaderBase parent)
     : base(rootReader)
 {
     Parent       = parent;
     _jail        = Root.CreateJail();
     Root.Current = this;
 }
Пример #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;
 }
Пример #5
0
 public void Dispose()
 {
     if (_root != null)
     {
         if (_deserializationActions != null)
         {
             _deserializationActions.RunOnce();
         }
         OnDispose();
         _root = null;
     }
 }
Пример #6
0
        /// <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);
        }
Пример #7
0
 protected ReaderBase( ReaderImpl root )
 {
     _root = root ?? (ReaderImpl)this;
 }
Пример #8
0
 public void Dispose()
 {
     if( _root != null )
     {
         if( _deserializationActions != null ) _deserializationActions.RunOnce();
         OnDispose();
         _root = null;
     }
 }
Пример #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;
 }
Пример #10
0
 protected ReaderBase(ReaderImpl root)
 {
     _root = root ?? (ReaderImpl)this;
 }
Пример #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;
 }
Пример #12
0
 /// <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;
 }