Beispiel #1
0
        /// <summary>
        /// Move iterator to the next part that has an associated filter and (re)initialize the
        /// relevant filter. 
        /// </summary>
        /// <remarks>
        /// This function results in _progress and _currentFilter being updated.
        /// </remarks>
        private void MoveToNextFilter()
        {            
            // Reset _isInternalFilter.
            _isInternalFilter = false;

            switch (_progress)
            {
                case Progress.FilteringNotStarted:

                    #region Progress.FilteringNotStarted

                    // Filtering not started yet. Start with core properties filter.

                    IndexingFilterMarshaler corePropertiesFilterMarshaler
                        = new IndexingFilterMarshaler(
                        new CorePropertiesFilter(_package.PackageProperties));

                    // Avoid exception on end of chunks from part filter.
                    corePropertiesFilterMarshaler.ThrowOnEndOfChunks = false;

                    _currentFilter = corePropertiesFilterMarshaler;
                    _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);
                    _isInternalFilter = true;
                    
                    // Update progress to indicate filtering core properties.
                    _progress = Progress.FilteringCoreProperties;
                    
                    break;

                    #endregion Progress.FilteringNotStarted

                case Progress.FilteringCoreProperties:

                    #region Progress.FilteringCoreProperties

                // Core properties were being filtered. Next move to content filtering.

                #endregion Progress.FilteringCoreProperties

                case Progress.FilteringContent:

                    #region Progress.FilteringContent

                    //
                    // Content being filtered. Move to next content part filter if it exists.
                    // Update progress to indicate filtering content if there is a next content
                    // filter, else to indicate filtering is completed.
                    //

                    if (_currentStream != null)
                    {
                        // Close the stream for the previous PackagePart.
                        _currentStream.Close();
                        _currentStream = null;
                    }

                    for (_currentFilter = null; _partIterator.MoveNext(); _currentFilter = null)
                    {
                        PackagePart currentPart = (PackagePart)_partIterator.Current;
                        ContentType contentType = currentPart.ValidatedContentType;

                        // Find the filter's CLSID based on the MIME content type.
                        string filterClsid = GetFilterClsid(contentType, currentPart.Uri);
                        if (filterClsid != null)
                        {
                            _currentFilter = GetFilterFromClsid(new Guid(filterClsid));
                            if (_currentFilter != null)
                            {
                                _currentStream = currentPart.GetStream();
                                ManagedIStream stream = new ManagedIStream(_currentStream);
                                try
                                {
                                    IPersistStreamWithArrays filterLoader = (IPersistStreamWithArrays)_currentFilter;
                                    filterLoader.Load(stream);
                                    _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);

                                    // Filter found and properly initialized. Search is over.
                                    break;
                                }
                                catch (InvalidCastException)
                                {
                                    // If a filter does not implement IPersistStream, then, by design, it should
                                    // be ignored.
                                }
                                catch (COMException)
                                {
                                    // Any initialization bug giving rise to an exception in the initialization
                                    // code should be ignored, since this will be due to faulty external code.
                                }
                                catch (IOException)
                                {
                                    // Initialization problem can be reported as IOException. See preceding comment.
                                }
                            }
                        }

                        //
                        // No valid externally registered filters found for this content part.
                        // If this is xaml part, use the internal XamlFilter.
                        //

                        if (BindUriHelper.IsXamlMimeType(contentType))
                        {
                            if (_currentStream == null)
                            {
                                _currentStream = currentPart.GetStream();
                            }

                            IndexingFilterMarshaler xamlFilterMarshaler
                                = new IndexingFilterMarshaler(new XamlFilter(_currentStream));

                            // Avoid exception on end of chunks from part filter.
                            xamlFilterMarshaler.ThrowOnEndOfChunks = false;

                            _currentFilter = xamlFilterMarshaler;
                            _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);
                            _isInternalFilter = true;

                            // Filter found and properly initialized. Search is over.
                            break;
                        }

                        if (_currentStream != null)
                        {
                            _currentStream.Close();
                            _currentStream = null;
                        }
                    }

                    if (_currentFilter == null)
                    {
                        // Update progress to indicate filtering is completed.
                        _progress = Progress.FilteringCompleted;
                    }
                    else
                    {
                        // Tell GetChunk that we are getting input from a new filter.
                        _firstChunkFromFilter = true;
 
                        // Update progress to indicate content being filtered.
                        _progress = Progress.FilteringContent;
                    }
                    break;

                    #endregion Progress.FilteringContent

                case Progress.FilteringCompleted:

                    #region Progress.FilteringCompleted

                    Debug.Assert(false);
                    break;

                    #endregion Progress.FilteringCompleted

                default:

                    #region Default

                    Debug.Assert(false);
                    break;

                    #endregion Default

            }
        }
Beispiel #2
0
        /// <summary>
        /// Move iterator to the next part that has an associated filter and (re)initialize the
        /// relevant filter.
        /// </summary>
        /// <remarks>
        /// This function results in _progress and _currentFilter being updated.
        /// </remarks>
        private void MoveToNextFilter()
        {
            // Reset _isInternalFilter.
            _isInternalFilter = false;

            switch (_progress)
            {
            case Progress.FilteringNotStarted:

                #region Progress.FilteringNotStarted

                // Filtering not started yet. Start with core properties filter.

                IndexingFilterMarshaler corePropertiesFilterMarshaler
                    = new IndexingFilterMarshaler(
                          new CorePropertiesFilter(_package.PackageProperties));

                // Avoid exception on end of chunks from part filter.
                corePropertiesFilterMarshaler.ThrowOnEndOfChunks = false;

                _currentFilter = corePropertiesFilterMarshaler;
                _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);
                _isInternalFilter = true;

                // Update progress to indicate filtering core properties.
                _progress = Progress.FilteringCoreProperties;

                break;

                #endregion Progress.FilteringNotStarted

            case Progress.FilteringCoreProperties:

                #region Progress.FilteringCoreProperties

                // Core properties were being filtered. Next move to content filtering.

                #endregion Progress.FilteringCoreProperties

            case Progress.FilteringContent:

                #region Progress.FilteringContent

                //
                // Content being filtered. Move to next content part filter if it exists.
                // Update progress to indicate filtering content if there is a next content
                // filter, else to indicate filtering is completed.
                //

                if (_currentStream != null)
                {
                    // Close the stream for the previous PackagePart.
                    _currentStream.Close();
                    _currentStream = null;
                }

                for (_currentFilter = null; _partIterator.MoveNext(); _currentFilter = null)
                {
                    PackagePart currentPart = (PackagePart)_partIterator.Current;
                    ContentType contentType = currentPart.ValidatedContentType();

                    // Find the filter's CLSID based on the MIME content type.
                    string filterClsid = GetFilterClsid(contentType, currentPart.Uri);
                    if (filterClsid != null)
                    {
                        _currentFilter = GetFilterFromClsid(new Guid(filterClsid));
                        if (_currentFilter != null)
                        {
                            _currentStream = currentPart.GetSeekableStream();
                            ManagedIStream stream = new ManagedIStream(_currentStream);
                            try
                            {
                                IPersistStreamWithArrays filterLoader = (IPersistStreamWithArrays)_currentFilter;
                                filterLoader.Load(stream);
                                _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);

                                // Filter found and properly initialized. Search is over.
                                break;
                            }
                            catch (InvalidCastException)
                            {
                                // If a filter does not implement IPersistStream, then, by design, it should
                                // be ignored.
                            }
                            catch (COMException)
                            {
                                // Any initialization bug giving rise to an exception in the initialization
                                // code should be ignored, since this will be due to faulty external code.
                            }
                            catch (IOException)
                            {
                                // Initialization problem can be reported as IOException. See preceding comment.
                            }
                        }
                    }

                    //
                    // No valid externally registered filters found for this content part.
                    // If this is xaml part, use the internal XamlFilter.
                    //

                    if (BindUriHelper.IsXamlMimeType(contentType))
                    {
                        if (_currentStream == null)
                        {
                            _currentStream = currentPart.GetSeekableStream();
                        }

                        IndexingFilterMarshaler xamlFilterMarshaler
                            = new IndexingFilterMarshaler(new XamlFilter(_currentStream));

                        // Avoid exception on end of chunks from part filter.
                        xamlFilterMarshaler.ThrowOnEndOfChunks = false;

                        _currentFilter = xamlFilterMarshaler;
                        _currentFilter.Init(_grfFlags, _cAttributes, _aAttributes);
                        _isInternalFilter = true;

                        // Filter found and properly initialized. Search is over.
                        break;
                    }

                    if (_currentStream != null)
                    {
                        _currentStream.Close();
                        _currentStream = null;
                    }
                }

                if (_currentFilter == null)
                {
                    // Update progress to indicate filtering is completed.
                    _progress = Progress.FilteringCompleted;
                }
                else
                {
                    // Tell GetChunk that we are getting input from a new filter.
                    _firstChunkFromFilter = true;

                    // Update progress to indicate content being filtered.
                    _progress = Progress.FilteringContent;
                }
                break;

                #endregion Progress.FilteringContent

            case Progress.FilteringCompleted:

                #region Progress.FilteringCompleted

                Debug.Assert(false);
                break;

                #endregion Progress.FilteringCompleted

            default:

                #region Default

                Debug.Assert(false);
                break;

                #endregion Default
            }
        }
        // Token: 0x06006CBB RID: 27835 RVA: 0x001F47E0 File Offset: 0x001F29E0
        private void MoveToNextFilter()
        {
            this._isInternalFilter = false;
            switch (this._progress)
            {
            case PackageFilter.Progress.FilteringNotStarted:
                this._currentFilter = new IndexingFilterMarshaler(new CorePropertiesFilter(this._package.PackageProperties))
                {
                    ThrowOnEndOfChunks = false
                };
                this._currentFilter.Init(this._grfFlags, this._cAttributes, this._aAttributes);
                this._isInternalFilter = true;
                this._progress         = PackageFilter.Progress.FilteringCoreProperties;
                return;

            case PackageFilter.Progress.FilteringCoreProperties:
            case PackageFilter.Progress.FilteringContent:
                if (this._currentStream != null)
                {
                    this._currentStream.Close();
                    this._currentStream = null;
                }
                this._currentFilter = null;
                while (this._partIterator.MoveNext())
                {
                    PackagePart packagePart          = (PackagePart)this._partIterator.Current;
                    ContentType validatedContentType = packagePart.ValidatedContentType;
                    string      filterClsid          = this.GetFilterClsid(validatedContentType, packagePart.Uri);
                    if (filterClsid != null)
                    {
                        this._currentFilter = this.GetFilterFromClsid(new Guid(filterClsid));
                        if (this._currentFilter != null)
                        {
                            this._currentStream = packagePart.GetStream();
                            ManagedIStream pstm = new ManagedIStream(this._currentStream);
                            try
                            {
                                IPersistStreamWithArrays persistStreamWithArrays = (IPersistStreamWithArrays)this._currentFilter;
                                persistStreamWithArrays.Load(pstm);
                                this._currentFilter.Init(this._grfFlags, this._cAttributes, this._aAttributes);
                                break;
                            }
                            catch (InvalidCastException)
                            {
                            }
                            catch (COMException)
                            {
                            }
                            catch (IOException)
                            {
                            }
                        }
                    }
                    if (BindUriHelper.IsXamlMimeType(validatedContentType))
                    {
                        if (this._currentStream == null)
                        {
                            this._currentStream = packagePart.GetStream();
                        }
                        this._currentFilter = new IndexingFilterMarshaler(new XamlFilter(this._currentStream))
                        {
                            ThrowOnEndOfChunks = false
                        };
                        this._currentFilter.Init(this._grfFlags, this._cAttributes, this._aAttributes);
                        this._isInternalFilter = true;
                        break;
                    }
                    if (this._currentStream != null)
                    {
                        this._currentStream.Close();
                        this._currentStream = null;
                    }
                    this._currentFilter = null;
                }
                if (this._currentFilter == null)
                {
                    this._progress = PackageFilter.Progress.FilteringCompleted;
                    return;
                }
                this._firstChunkFromFilter = true;
                this._progress             = PackageFilter.Progress.FilteringContent;
                break;

            case PackageFilter.Progress.FilteringCompleted:
                break;

            default:
                return;
            }
        }