IExtenderListService Interface

 

Provides an interface that can list extender providers.

Namespace:   System.ComponentModel.Design
Assembly:  System (in System.dll)

public interface class IExtenderListService

NameDescription
System_CAPS_pubmethodGetExtenderProviders()

Gets the set of extender providers for the component.

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.

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

#using <system.dll>
#using <system.drawing.dll>
#using <system.windows.forms.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Windows::Forms;

namespace ExtenderListServiceExample
{
   // This control lists any active extender providers.
   public ref class ExtenderListServiceControl: public UserControl
   {
   private:
      IExtenderListService^ extenderListService;
      array<String^>^extenderNames;

   public:
      ExtenderListServiceControl()
      {
         this->Width = 600;
      }

      property ISite^ Site 
      {
         // Queries the IExtenderListService when the control is sited
         // in design mode.
         virtual ISite^ get() override
         {
            return __super::Site;
         }

         virtual void set( ISite^ value ) override
         {
            __super::Site = value;
            if ( this->DesignMode )
            {
               extenderListService = dynamic_cast<IExtenderListService^>(this->GetService( IExtenderListService::typeid ));
               if ( extenderListService != nullptr )
               {
                  array<IExtenderProvider^>^extenders = extenderListService->GetExtenderProviders();
                  extenderNames = gcnew array<String^>(extenders->Length);
                  for ( int i = 0; i < extenders->Length; i++ )
                     extenderNames[ i ] = String::Concat( "ExtenderProvider #", i.ToString(), ":  ", extenders[ i ]->GetType()->FullName );
               }
            }
            else
            {
               extenderListService = nullptr;
            }
         }
      }

   protected:

      // Draws a list of any active extender providers
      virtual void OnPaint( PaintEventArgs^ e ) override
      {
         if ( extenderNames->Length == 0 )
                  e->Graphics->DrawString( "No active extender providers", gcnew System::Drawing::Font( "Arial",9 ), gcnew SolidBrush( Color::Black ), 10, 10 );
         else
                  e->Graphics->DrawString( "List of types of active extender providers", gcnew System::Drawing::Font( "Arial",9 ), gcnew SolidBrush( Color::Black ), 10, 10 );

         for ( int i = 0; i < extenderNames->Length; i++ )
            e->Graphics->DrawString( extenderNames[ i ], gcnew System::Drawing::Font( "Arial",8 ), gcnew SolidBrush( Color::Black ), 10, 25 + (i * 10) );
      }
   };
}

.NET Framework
Available since 1.1
Return to top
Show: