/// <summary>
        /// Returns service objects associated with this control.
        /// This method should be called by IServiceProvider.GetService implementation 
        /// for DocumentPageView or subclasses.
        /// </summary>
        /// <param name="serviceType">Specifies the type of service object to get.</param>
        protected object GetService(Type serviceType)
        {
            object service = null;
            if (serviceType == null)
            {
                throw new ArgumentNullException("serviceType");
            }
            CheckDisposed();

            // No service is available if the Content does not provide
            // any services.
            if (_documentPaginator != null && _documentPaginator is IServiceProvider)
            {
                // Following services are available:
                // (1) TextView - wrapper for TextView exposed by the current page.
                // (2) TextContainer - the service object is retrieved from DocumentPaginator.
                if (serviceType == typeof(ITextView))
                {
                    if (_textView == null)
                    {
                        ITextContainer tc = ((IServiceProvider)_documentPaginator).GetService(typeof(ITextContainer)) as ITextContainer;
                        if (tc != null)
                        {
                            _textView = new DocumentPageTextView(this, tc);
                        }
                    }
                    service = _textView;
                }
                else if (serviceType == typeof(TextContainer) || serviceType == typeof(ITextContainer))
                {
                    service = ((IServiceProvider)_documentPaginator).GetService(serviceType);
                }
            }
            return service;
        }
        /// <summary>
        /// Dispose the object.
        /// </summary>
        protected void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                // Cleanup all state associated with Paginator.
                if (_documentPaginator != null)
                {
                    _documentPaginator.GetPageCompleted -= new GetPageCompletedEventHandler(HandleGetPageCompleted);
                    _documentPaginator.PagesChanged -= new PagesChangedEventHandler(HandlePagesChanged);
                    _documentPaginator.CancelAsync(this);
                    DisposeCurrentPage();
                    DisposeAsyncPage();
                }
                Invariant.Assert(_documentPage == null);
                Invariant.Assert(_documentPageAsync == null);
                _documentPaginator = null;
                _textView = null;
            }
        }