コード例 #1
0
        internal static STAT_CHUNK MarshalChunk(ManagedChunk chunk)
        {
            STAT_CHUNK result = default(STAT_CHUNK);

            result.idChunk = chunk.ID;
            Invariant.Assert(chunk.BreakType >= CHUNK_BREAKTYPE.CHUNK_NO_BREAK && chunk.BreakType <= CHUNK_BREAKTYPE.CHUNK_EOC);
            result.breakType = chunk.BreakType;
            Invariant.Assert(chunk.Flags >= (CHUNKSTATE)0 && chunk.Flags <= (CHUNKSTATE.CHUNK_TEXT | CHUNKSTATE.CHUNK_VALUE | CHUNKSTATE.CHUNK_FILTER_OWNED_VALUE));
            result.flags          = chunk.Flags;
            result.locale         = chunk.Locale;
            result.idChunkSource  = chunk.ChunkSource;
            result.cwcStartSource = chunk.StartSource;
            result.cwcLenSource   = chunk.LenSource;
            IndexingFilterMarshaler.MarshalFullPropSpec(chunk.Attribute, ref result.attribute);
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Constructor. 
        /// </summary>
        /// <param name="encryptedPackage">EncryptedPackageEnvelope to filter on</param>
        internal EncryptedPackageFilter(EncryptedPackageEnvelope encryptedPackage)
        {
            if (encryptedPackage == null)
            {
                throw new ArgumentNullException("encryptedPackage");
            }

            //
            // Since CorePropertiesFilter is implemented as
            // a managed filter (supports IManagedFilter interface),
            // IndexingFilterMarshaler is used to get IFilter interface out of it.
            //
            _filter = new IndexingFilterMarshaler(
                new CorePropertiesFilter(
                encryptedPackage.PackageProperties
                ));
        }
コード例 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="encryptedPackage">EncryptedPackageEnvelope to filter on</param>
        internal EncryptedPackageFilter(EncryptedPackageEnvelope encryptedPackage)
        {
            if (encryptedPackage == null)
            {
                throw new ArgumentNullException("encryptedPackage");
            }

            //
            // Since CorePropertiesFilter is implemented as
            // a managed filter (supports IManagedFilter interface),
            // IndexingFilterMarshaler is used to get IFilter interface out of it.
            //
            _filter = new IndexingFilterMarshaler(
                new CorePropertiesFilter(
                    encryptedPackage.PackageProperties
                    ));
        }
コード例 #4
0
        public STAT_CHUNK GetChunk()
        {
            ManagedChunk chunk = this._implementation.GetChunk();

            if (chunk != null)
            {
                return(IndexingFilterMarshaler.MarshalChunk(chunk));
            }
            if (this.ThrowOnEndOfChunks)
            {
                throw new COMException(SR.Get("FilterEndOfChunks"), -2147215616);
            }
            return(new STAT_CHUNK
            {
                idChunk = 0U
            });
        }
コード例 #5
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
            }
        }
コード例 #6
0
ファイル: PackageFilter.cs プロジェクト: JianwenSun/cc
        /// <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

            }
        }
コード例 #7
0
 internal static void MarshalFullPropSpec(ManagedFullPropSpec fullPropSpec, ref FULLPROPSPEC native)
 {
     native.guid = fullPropSpec.Guid;
     IndexingFilterMarshaler.MarshalPropSpec(fullPropSpec.Property, ref native.property);
 }
コード例 #8
0
 public IntPtr GetValue()
 {
     return(IndexingFilterMarshaler.MarshalPropVariant(this._implementation.GetValue()));
 }
コード例 #9
0
 public void GetText(ref uint bufCharacterCount, IntPtr pBuffer)
 {
     IndexingFilterMarshaler.MarshalStringToPtr(this._implementation.GetText((int)(bufCharacterCount - 1U)), ref bufCharacterCount, pBuffer);
 }
コード例 #10
0
 // Token: 0x06006C34 RID: 27700 RVA: 0x001F1FE0 File Offset: 0x001F01E0
 public IFILTER_FLAGS Init(IFILTER_INIT grfFlags, uint cAttributes, FULLPROPSPEC[] aAttributes)
 {
     ManagedFullPropSpec[] aAttributes2 = IndexingFilterMarshaler.MarshalFullPropSpecArray(cAttributes, aAttributes);
     return(this._implementation.Init(grfFlags, aAttributes2));
 }