Читати англійською Редагувати

Поділитися через


IExtenderListService Interface

Definition

Provides an interface that can list extender providers.

public interface IExtenderListService

Examples

The following example demonstrates using the IExtenderListService to obtain the set of currently active extender providers.

using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace ExtenderListServiceExample
{
    // This control lists any active extender providers.
    public class ExtenderListServiceControl : System.Windows.Forms.UserControl
    {		
        private IExtenderListService extenderListService;
        private string[] extenderNames;

        public ExtenderListServiceControl()
        {			
            extenderNames = new string[0];
            this.Width = 600;
        }

        // Queries the IExtenderListService when the control is sited 
        // in design mode.
        public override System.ComponentModel.ISite Site
        {
            get
            {
                return base.Site;
            }
            set
            {
                base.Site = value;
                if( this.DesignMode )
                {
                    extenderListService = (IExtenderListService)this.GetService(typeof(IExtenderListService));
                    if( extenderListService != null )
                    {
                        IExtenderProvider[] extenders = extenderListService.GetExtenderProviders();
                        extenderNames = new string[extenders.Length];
                        for( int i=0; i<extenders.Length; i++ )
                            extenderNames[i] = "ExtenderProvider #"+i.ToString()+":  "+extenders[i].GetType().FullName;
                    }
                }
                else
                {
                    extenderListService = null;
                    extenderNames = new string[0];
                }
            }
        }

        // Draws a list of any active extender providers
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if( extenderNames.Length == 0 )
                e.Graphics.DrawString("No active extender providers", new Font("Arial", 9), new SolidBrush(Color.Black), 10, 10);
            else
                e.Graphics.DrawString("List of types of active extender providers", new Font("Arial", 9), new SolidBrush(Color.Black), 10, 10);
            for(int i=0; i<extenderNames.Length; i++)
                e.Graphics.DrawString(extenderNames[i], new Font("Arial", 8), new SolidBrush(Color.Black), 10, 25+(i*10));
        }		
    }
}

Remarks

A site can implement this service if it wants to provide a list of extender providers. By default, the list of extenders is generated by querying each component in the container that implements IExtenderProvider for the extenders each provides. By implementing this interface on a component site, a container can override the list of providers.

Methods

GetExtenderProviders()

Gets the set of extender providers for the component.

Applies to

Продукт Версії
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also