ComponentDesigner.GetService(Type) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
디자이너 구성 요소의 디자인 모드 사이트에서 지정된 서비스 유형을 검색하려고 시도합니다.
protected:
virtual System::Object ^ GetService(Type ^ serviceType);
protected virtual object GetService(Type serviceType);
protected virtual object? GetService(Type serviceType);
abstract member GetService : Type -> obj
override this.GetService : Type -> obj
Protected Overridable Function GetService (serviceType As Type) As Object
매개 변수
- serviceType
- Type
요청할 서비스 유형입니다.
반품
요청된 서비스를 구현하는 개체이거나 null 서비스를 확인할 수 없는 경우
예제
다음 코드 예제에서는 메서드를 사용하여 GetService 디자이너 서비스에 액세스하는 방법을 보여 줍니다.
// This utility method connects the designer to various
// services it will use.
void InitializeServices()
{
// Acquire a reference to DesignerActionService.
actionService =
GetService(typeof(DesignerActionService))
as DesignerActionService;
// Acquire a reference to DesignerActionUIService.
actionUiService =
GetService(typeof(DesignerActionUIService))
as DesignerActionUIService;
// Acquire a reference to IComponentChangeService.
changeService =
GetService(typeof(IComponentChangeService))
as IComponentChangeService;
// Hook the IComponentChangeService events.
if (changeService != null)
{
changeService.ComponentChanged +=
ChangeService_ComponentChanged;
changeService.ComponentAdded +=
ChangeService_ComponentAdded;
changeService.ComponentRemoved +=
changeService_ComponentRemoved;
}
// Acquire a reference to ISelectionService.
selectionService =
GetService(typeof(ISelectionService))
as ISelectionService;
// Hook the SelectionChanged event.
if (selectionService != null)
{
selectionService.SelectionChanged +=
selectionService_SelectionChanged;
}
// Acquire a reference to IDesignerEventService.
eventService =
GetService(typeof(IDesignerEventService))
as IDesignerEventService;
if (eventService != null)
{
eventService.ActiveDesignerChanged +=
eventService_ActiveDesignerChanged;
}
// Acquire a reference to IDesignerHost.
host =
GetService(typeof(IDesignerHost))
as IDesignerHost;
// Acquire a reference to IDesignerOptionService.
optionService =
GetService(typeof(IDesignerOptionService))
as IDesignerOptionService;
// Acquire a reference to IEventBindingService.
eventBindingService =
GetService(typeof(IEventBindingService))
as IEventBindingService;
// Acquire a reference to IExtenderListService.
listService =
GetService(typeof(IExtenderListService))
as IExtenderListService;
// Acquire a reference to IReferenceService.
referenceService =
GetService(typeof(IReferenceService))
as IReferenceService;
// Acquire a reference to ITypeResolutionService.
typeResService =
GetService(typeof(ITypeResolutionService))
as ITypeResolutionService;
// Acquire a reference to IComponentDiscoveryService.
componentDiscoveryService =
GetService(typeof(IComponentDiscoveryService))
as IComponentDiscoveryService;
// Acquire a reference to IToolboxService.
toolboxService =
GetService(typeof(IToolboxService))
as IToolboxService;
// Acquire a reference to UndoEngine.
undoEng =
GetService(typeof(UndoEngine))
as UndoEngine;
if (undoEng != null)
{
_ = MessageBox.Show("UndoEngine");
}
}
' This utility method connects the designer to various
' services it will use.
Private Sub InitializeServices()
' Acquire a reference to DesignerActionService.
Me.actionService = GetService(GetType(DesignerActionService))
' Acquire a reference to DesignerActionUIService.
Me.actionUiService = GetService(GetType(DesignerActionUIService))
' Acquire a reference to IComponentChangeService.
Me.changeService = GetService(GetType(IComponentChangeService))
' Hook the IComponentChangeService events.
If (Me.changeService IsNot Nothing) Then
AddHandler Me.changeService.ComponentChanged, AddressOf ChangeService_ComponentChanged
AddHandler Me.changeService.ComponentAdded, AddressOf ChangeService_ComponentAdded
AddHandler Me.changeService.ComponentRemoved, AddressOf changeService_ComponentRemoved
End If
' Acquire a reference to ISelectionService.
Me.selectionService = GetService(GetType(ISelectionService))
' Hook the SelectionChanged event.
If (Me.selectionService IsNot Nothing) Then
AddHandler Me.selectionService.SelectionChanged, AddressOf selectionService_SelectionChanged
End If
' Acquire a reference to IDesignerEventService.
Me.eventService = GetService(GetType(IDesignerEventService))
If (Me.eventService IsNot Nothing) Then
AddHandler Me.eventService.ActiveDesignerChanged, AddressOf eventService_ActiveDesignerChanged
End If
' Acquire a reference to IDesignerHost.
Me.host = GetService(GetType(IDesignerHost))
' Acquire a reference to IDesignerOptionService.
Me.optionService = GetService(GetType(IDesignerOptionService))
' Acquire a reference to IEventBindingService.
Me.eventBindingService = GetService(GetType(IEventBindingService))
' Acquire a reference to IExtenderListService.
Me.listService = GetService(GetType(IExtenderListService))
' Acquire a reference to IReferenceService.
Me.referenceService = GetService(GetType(IReferenceService))
' Acquire a reference to ITypeResolutionService.
Me.typeResService = GetService(GetType(ITypeResolutionService))
' Acquire a reference to IComponentDiscoveryService.
Me.componentDiscoveryService = GetService(GetType(IComponentDiscoveryService))
' Acquire a reference to IToolboxService.
Me.toolboxService = GetService(GetType(IToolboxService))
' Acquire a reference to UndoEngine.
Me.undoEng = GetService(GetType(UndoEngine))
If (Me.undoEng IsNot Nothing) Then
MessageBox.Show("UndoEngine")
End If
End Sub
설명
이 메서드의 기본 구현은 구성 요소의 사이트에서 서비스를 요청합니다.