コード例 #1
0
ファイル: ReaderImplSub.cs プロジェクト: Paty-B/ck-core
 internal ReaderImplSub( ReaderImpl rootReader, ReaderBase parent )
     : base(rootReader)
 {
     Parent = parent;
     _jail = Root.CreateJail();
     Root.Current = this;
 }
コード例 #2
0
ファイル: ReaderBookmark.cs プロジェクト: Paty-B/ck-core
        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
ファイル: ReaderImplSub.cs プロジェクト: Paty-B/ck-core
 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
ファイル: ReaderBase.cs プロジェクト: Paty-B/ck-core
 protected ReaderBase( ReaderImpl root )
 {
     _root = root ?? (ReaderImpl)this;
 }
コード例 #8
0
ファイル: ReaderBase.cs プロジェクト: Paty-B/ck-core
 public void Dispose()
 {
     if( _root != null )
     {
         if( _deserializationActions != null ) _deserializationActions.RunOnce();
         OnDispose();
         _root = null;
     }
 }
コード例 #9
0
ファイル: ReaderBookmark.cs プロジェクト: Paty-B/ck-core
 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
ファイル: ReaderImpl.cs プロジェクト: Paty-B/ck-core
 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;
 }