コード例 #1
0
ファイル: Baml2006Reader.cs プロジェクト: sjyanxin/WPFSource
        protected override void Dispose(bool disposing)
        { 
            if (_binaryReader != null)
            {
                if (_settings.OwnsStream)
                { 
                    SharedStream sharedStream = _binaryReader.BaseStream as SharedStream;
                    if (sharedStream != null && sharedStream.SharedCount < 1) 
                    { 
                        // The reader is responsible for the streams lifetime and no one is sharing the stream
                        _binaryReader.Close(); 
                    }
                }

                _binaryReader = null; 
                _context = null;
            } 
        } 
コード例 #2
0
ファイル: Baml2006Reader.cs プロジェクト: sjyanxin/WPFSource
        private void Initialize(Stream stream, 
            Baml2006SchemaContext schemaContext, 
            Baml2006ReaderSettings settings)
        { 
            schemaContext.Settings = settings;
            _settings = settings;
            _context = new Baml2006ReaderContext(schemaContext);
            _xamlMainNodeQueue = new XamlNodeQueue(schemaContext); 
            _xamlNodesReader = _xamlMainNodeQueue.Reader;
            _xamlNodesWriter = _xamlMainNodeQueue.Writer; 
            _lookingForAKeyOnAMarkupExtensionInADictionaryDepth = -1; 

            _isBinaryProvider = !settings.ValuesMustBeString; 

            // Since the reader owns the stream and is responsible for its lifetime
            // it can safely hand out shared streams.
            if (_settings.OwnsStream) 
            {
                stream = new SharedStream(stream); 
            } 

            _binaryReader = new BamlBinaryReader(stream); 

            _context.TemplateStartDepth = -1;

            if (!_settings.IsBamlFragment) 
            {
                Process_Header(); 
            } 
        }