IExtenderProviderService 인터페이스
디자인 타임에 extender 공급자를 추가하고 제거할 수 있는 인터페이스를 제공합니다.
네임스페이스: System.ComponentModel.Design
어셈블리: System(system.dll)
구문
‘선언
Public Interface IExtenderProviderService
‘사용 방법
Dim instance As IExtenderProviderService
public interface IExtenderProviderService
public interface class IExtenderProviderService
public interface IExtenderProviderService
public interface IExtenderProviderService
설명
일반적으로 컨테이너에 추가된 구성 요소만이 extender 공급자를 제공합니다. IExtenderProviderService를 사용하면 컨테이너에 없는 개체에 이 기능을 확장할 수 있습니다.
예제
다음 예제에서는 디자이너에서 IExtenderProviderService를 사용하여 IExtenderProvider 구현을 추가하고 제거합니다.
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
' This designer adds a ComponentExtender extender provider,
' and removes it when the designer is destroyed.
Public Class ExtenderServiceDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
' A local reference to an obtained IExtenderProviderService.
Private localExtenderServiceReference As IExtenderProviderService
' An IExtenderProvider that this designer supplies.
Private extender As ComponentExtender
Public Sub New()
End Sub
Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
MyBase.Initialize(component)
' Attempts to obtain an IExtenderProviderService.
Dim extenderService As IExtenderProviderService = CType(component.Site.GetService(GetType(IExtenderProviderService)), IExtenderProviderService)
If Not (extenderService Is Nothing) Then
' If the service was obtained, adds a ComponentExtender
' that adds an "ExtenderIndex" integer property to the
' designer's component.
extender = New ComponentExtender()
extenderService.AddExtenderProvider(extender)
localExtenderServiceReference = extenderService
Else
MessageBox.Show("Could not obtain an IExtenderProviderService.")
End If
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
' Removes any previously added extender provider.
If Not (localExtenderServiceReference Is Nothing) Then
localExtenderServiceReference.RemoveExtenderProvider(extender)
localExtenderServiceReference = Nothing
End If
End Sub
End Class
' IExtenderProviderImplementation that adds an integer property
' named "ExtenderIndex" to any design-mode document object.
<ProvidePropertyAttribute("ExtenderIndex", GetType(IComponent))> _
Public Class ComponentExtender
Implements System.ComponentModel.IExtenderProvider
' Stores the value of the property to extend a component with.
Public index As Integer = 0
Public Sub New()
End Sub
' Extends any type of object.
Public Function CanExtend(ByVal extendee As Object) As Boolean Implements IExtenderProvider.CanExtend
Return True
End Function
Public Function GetExtenderIndex(ByVal component As IComponent) As Integer
Return index
End Function
Public Sub SetExtenderIndex(ByVal component As IComponent, ByVal index As Integer)
Me.index = index
End Sub
End Class
' Example UserControl associated with the ExtenderServiceDesigner.
<DesignerAttribute(GetType(ExtenderServiceDesigner))> _
Public Class ExtenderServiceTestControl
Inherits System.Windows.Forms.UserControl
Public Sub New()
End Sub
End Class
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace ExtenderServiceExample
{
// This designer adds a ComponentExtender extender provider,
// and removes it when the designer is destroyed.
public class ExtenderServiceDesigner : System.Windows.Forms.Design.ControlDesigner
{
// A local reference to an obtained IExtenderProviderService.
private IExtenderProviderService localExtenderServiceReference;
// An IExtenderProvider that this designer supplies.
private ComponentExtender extender;
public ExtenderServiceDesigner()
{
}
public override void Initialize(System.ComponentModel.IComponent component)
{
base.Initialize(component);
// Attempts to obtain an IExtenderProviderService.
IExtenderProviderService extenderService = (IExtenderProviderService)component.Site.GetService(typeof(IExtenderProviderService));
if( extenderService != null )
{
// If the service was obtained, adds a ComponentExtender
// that adds an "ExtenderIndex" integer property to the
// designer's component.
extender = new ComponentExtender();
extenderService.AddExtenderProvider( extender );
localExtenderServiceReference = extenderService;
}
else
MessageBox.Show("Could not obtain an IExtenderProviderService.");
}
protected override void Dispose(bool disposing)
{
// Removes any previously added extender provider.
if( localExtenderServiceReference != null )
{
localExtenderServiceReference.RemoveExtenderProvider( extender );
localExtenderServiceReference = null;
}
}
}
// IExtenderProviderImplementation that adds an integer property
// named "ExtenderIndex" to any design-mode document object.
[ProvidePropertyAttribute("ExtenderIndex", typeof(IComponent))]
public class ComponentExtender : System.ComponentModel.IExtenderProvider
{
// Stores the value of the property to extend a component with.
public int index = 0;
public ComponentExtender()
{
}
public bool CanExtend(object extendee)
{
// Extends any type of object.
return true;
}
public int GetExtenderIndex(IComponent component)
{
return index;
}
public void SetExtenderIndex(IComponent component, int index)
{
this.index = index;
}
}
// Example UserControl associated with the ExtenderServiceDesigner.
[DesignerAttribute(typeof(ExtenderServiceDesigner))]
public class ExtenderServiceTestControl : System.Windows.Forms.UserControl
{
public ExtenderServiceTestControl()
{
}
}
}
#using <system.dll>
#using <system.design.dll>
#using <system.windows.forms.dll>
#using <system.drawing.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;
// IExtenderProviderImplementation that adds an integer property
// named "ExtenderIndex" to any design-mode document object.
[ProvidePropertyAttribute("ExtenderIndex",IComponent::typeid)]
public ref class ComponentExtender: public IExtenderProvider
{
public:
// Stores the value of the property to extend a component with.
int index;
ComponentExtender()
{
index = 0;
}
virtual bool CanExtend( Object^ /*extendee*/ )
{
// Extends any type of object.
return true;
}
int GetExtenderIndex( IComponent^ /*component*/ )
{
return index;
}
void SetExtenderIndex( IComponent^ /*component*/, int index )
{
this->index = index;
}
};
// This designer adds a ComponentExtender extender provider,
// and removes it when the designer is destroyed.
public ref class ExtenderServiceDesigner: public ControlDesigner
{
private:
// A local reference to an obtained IExtenderProviderService.
IExtenderProviderService^ localExtenderServiceReference;
// An IExtenderProvider that this designer supplies.
ComponentExtender^ extender;
public:
ExtenderServiceDesigner(){}
virtual void Initialize( IComponent^ component ) override
{
ControlDesigner::Initialize( component );
// Attempts to obtain an IExtenderProviderService.
IExtenderProviderService^ extenderService = dynamic_cast<IExtenderProviderService^>(component->Site->GetService( IExtenderProviderService::typeid ));
if ( extenderService != nullptr )
{
// If the service was obtained, adds a ComponentExtender
// that adds an "ExtenderIndex" integer property to the
// designer's component.
extender = gcnew ComponentExtender;
extenderService->AddExtenderProvider( extender );
localExtenderServiceReference = extenderService;
}
else
MessageBox::Show( "Could not obtain an IExtenderProviderService." );
}
~ExtenderServiceDesigner()
{
// Removes any previously added extender provider.
if ( localExtenderServiceReference != nullptr )
{
localExtenderServiceReference->RemoveExtenderProvider( extender );
localExtenderServiceReference = nullptr;
}
}
};
// Example UserControl associated with the ExtenderServiceDesigner.
[DesignerAttribute(ExtenderServiceDesigner::typeid)]
public ref class ExtenderServiceTestControl: public UserControl
{
public:
ExtenderServiceTestControl(){}
};
package ExtenderServiceExample;
import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Windows.Forms.*;
import System.Windows.Forms.Design.*;
// This designer adds a ComponentExtender extender provider,
// and removes it when the designer is destroyed.
public class ExtenderServiceDesigner extends
System.Windows.Forms.Design.ControlDesigner
{
// A local reference to an obtained IExtenderProviderService.
private IExtenderProviderService localExtenderServiceReference;
// An IExtenderProvider that this designer supplies.
private ComponentExtender extender;
public ExtenderServiceDesigner()
{
} //ExtenderServiceDesigner
public void Initialize(System.ComponentModel.IComponent component)
{
super.Initialize(component);
// Attempts to obtain an IExtenderProviderService.
IExtenderProviderService extenderService = (IExtenderProviderService)
component.get_Site().GetService(IExtenderProviderService.class.
ToType());
if (extenderService != null) {
// If the service was obtained, adds a ComponentExtender
// that adds an "ExtenderIndex" integer property to the
// designer's component.
extender = new ComponentExtender();
extenderService.AddExtenderProvider(extender);
localExtenderServiceReference = extenderService;
}
else {
MessageBox.Show("Could not obtain an IExtenderProviderService.");
}
} //Initialize
protected void Dispose(boolean disposing)
{
// Removes any previously added extender provider.
if (localExtenderServiceReference != null) {
localExtenderServiceReference.RemoveExtenderProvider(extender);
localExtenderServiceReference = null;
}
} //Dispose
} //ExtenderServiceDesigner
// IExtenderProviderImplementation that adds an integer property
// named "ExtenderIndex" to any design-mode document object.
/** @ attribute ProvidePropertyAttribute("ExtenderIndex",
IComponent.class.ToType())
*/
public class ComponentExtender implements
System.ComponentModel.IExtenderProvider
{
// Stores the value of the property to extend a component with.
public int index = 0;
public ComponentExtender()
{
} //ComponentExtender
public boolean CanExtend(Object extendee)
{
// Extends any type of object.
return true;
} //CanExtend
public int GetExtenderIndex(IComponent component)
{
return index;
} //GetExtenderIndex
public void SetExtenderIndex(IComponent component, int index)
{
this.index = index;
} //SetExtenderIndex
} //ComponentExtender
// Example UserControl associated with the ExtenderServiceDesigner.
/** @ attribute DesignerAttribute(ExtenderServiceDesigner.class.ToType())
*/
public class ExtenderServiceTestControl extends
System.Windows.Forms.UserControl
{
public ExtenderServiceTestControl()
{
} //ExtenderServiceTestControl
} //ExtenderServiceTestControl
플랫폼
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
참고 항목
참조
IExtenderProviderService 멤버
System.ComponentModel.Design 네임스페이스
IExtenderProvider 인터페이스