コード例 #1
0
        //-------------------------------------------------------------------
        //
        //  IServiceProvider Members
        //
        //-------------------------------------------------------------------

        #region IServiceProvider Members

        /// <summary>
        /// Gets the service object of the specified type.
        /// </summary>
        /// <param name="serviceType">
        /// An object that specifies the type of service object to get.
        /// </param>
        /// <returns>
        /// A service object of type serviceType. A null reference if there is no
        /// service object of type serviceType.
        /// </returns>
        object IServiceProvider.GetService(Type serviceType)
        {
            object service = null;

            if (serviceType == typeof(ITextView))
            {
                if (_textView == null && _document != null)
                {
                    _textView = new DocumentPageTextView(this, _document.StructuralCache.TextContainer);
                }
                service = _textView;
            }
            else if (serviceType == typeof(ITextContainer))
            {
                if (Document != null)
                {
                    service = Document.StructuralCache.TextContainer as TextContainer;
                }
            }

            return(service);
        }
コード例 #2
0
        //-------------------------------------------------------------------
        //
        //  IServiceProvider Members
        //
        //-------------------------------------------------------------------

        #region IServiceProvider Members

        /// <summary>
        /// Gets the service object of the specified type.
        /// </summary>
        /// <param name="serviceType">
        /// An object that specifies the type of service object to get.
        /// </param>
        /// <returns>
        /// A service object of type serviceType. A null reference if there is no 
        /// service object of type serviceType.
        /// </returns>
        object IServiceProvider.GetService(Type serviceType)
        {
            object service = null;

            if (serviceType == typeof(ITextView))
            {
                if (_textView == null && _document != null)
                {
                    _textView = new DocumentPageTextView(this, _document.StructuralCache.TextContainer);
                }
                service = _textView;
            }
            else if (serviceType == typeof(ITextContainer))
            {
                if (Document != null)
                {
                    service = Document.StructuralCache.TextContainer as TextContainer;
                }
            }
            
            return service;
        }
コード例 #3
0
        /// <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;
        }