Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
LocalizationExtenderProvider Class
Collapse the table of content
Expand the table of content

LocalizationExtenderProvider Class

Note: This API is now obsolete. The non-obsolete alternative is CodeDomLocalizationProvider.

Provides design-time support for localization features to a root designer.


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

<ObsoleteAttribute("This class has been deprecated. Use CodeDomLocalizationProvider instead.  http://go.microsoft.com/fwlink/?linkid=14202")> _
Public Class LocalizationExtenderProvider _
	Implements IExtenderProvider, IDisposable

The LocalizationExtenderProvider type exposes the following members.

Public methodLocalizationExtenderProviderInitializes a new instance of the LocalizationExtenderProvider class using the specified service provider and base component.

Public methodCanExtendIndicates whether this object can provide its extender properties to the specified object.
Public methodDisposeDisposes of the resources (other than memory) used by the LocalizationExtenderProvider.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the LocalizationExtenderProvider and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLanguageGets the current resource culture for the specified object.
Public methodGetLoadLanguageGets the default resource culture to use when initializing the values of a localized object at design time.
Public methodGetLocalizableGets a value indicating whether the specified object supports resource localization.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodResetLanguageResets the resource culture for the specified object.
Public methodSetLanguageSets the current resource culture for the specified object to the specified resource culture.
Public methodSetLocalizableSets a value indicating whether the specified object supports localized resources.
Public methodShouldSerializeLanguageGets a value indicating whether the specified object must have its localizable values persisted in a resource.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

LocalizationExtenderProvider can extend an IRootDesigner with a set of properties and methods that provide support for the .NET Framework localization architecture. For more about using resources, see Localization.

The localization support architecture enables designers to initialize component properties using resource files that can be swapped at run time to support a variety of languages, culture-specific styles and dynamically configurable features. You can use the methods of this class to enable designers and code generating serializers to load from resources and build initialization code that uses localization features.

The default serializers that ship with Visual Studio are already capable of localizing components and controls, but they only do so if they locate support for the .NET Framework localization architecture. To detect the presence of localization support, the serialization system must locate a public Boolean property named "Localizable" on the root designer component. If a serializer finds this property, it searches for a property of type CultureInfo named "Language" to determine the current resource configuration. Default serializers use these properties to determine if it should localize any localizable resources of the component, and if so, what CultureInfo format the resource information should be saved in.

The following code example adds a LocalizationExtenderProvider to a component.

' Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
extender = New LocalizationExtenderProvider(Me.component_.Site, Me.component_)

The following code example includes an example component and designer. The designer uses a LocalizationExtenderProvider to add localization support properties for the component.

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Diagnostics
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

' This example demonstrates adding localization support to a component hierarchy from a  
' custom IRootDesigner using the LocalizationExtenderProvider class. 

' RootViewDesignerComponent is a component associated with the SampleRootDesigner 
' IRootDesigner that provides LocalizationExtenderProvider localization support. 
' This derived class is included at the top of this example to enable  
' easy launching of designer view without having to put the class in its own file. 
Public Class RootViewDesignerComponent
    Inherits RootDesignedComponent

    Public Sub New()
    End Sub 
End Class 

' The following attribute associates the RootDesignedComponent with the RootDesignedComponent component.
<Designer(GetType(SampleRootDesigner), GetType(IRootDesigner))> _
Public Class RootDesignedComponent
    Inherits Component

    Public Sub New()
    End Sub 
End Class 

' Example IRootDesigner implementation demonstrates LocalizationExtenderProvider support. 
Friend Class SampleRootDesigner
    Implements IRootDesigner

    ' RootDesignerView Control provides a full region designer view for this root designer's associated component. 
    Private m_view As RootDesignerView
    ' Stores reference to the LocalizationExtenderProvider this designer adds, in order to remove it on Dispose. 
    Private extender As LocalizationExtenderProvider
    ' Internally stores the IDesigner's component reference 
    Private component_ As IComponent

    ' Adds a LocalizationExtenderProvider for the component this designer is initialized to support. 
    Public Sub Initialize(ByVal component As System.ComponentModel.IComponent) Implements IRootDesigner.Initialize
        Me.component_ = component

        ' If no extender from this designer is active... 
        If extender Is Nothing Then 
            ' Adds a LocalizationExtenderProvider that provides localization support properties to the specified component.
            extender = New LocalizationExtenderProvider(Me.component_.Site, Me.component_)
        End If 
    End Sub 

    ' Provides a RootDesignerView object that supports ViewTechnology.WindowsForms. 
    Function GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView

        If technology <> ViewTechnology.WindowsForms Then 
            Throw New ArgumentException("Not a supported view technology", "technology")
        End If 
        If m_view Is Nothing Then 
            ' Create the view control. In this example, a Control of type RootDesignerView is used. 
            ' A WindowsForms ViewTechnology view provider requires a class that inherits from Control.
            m_view = New RootDesignerView(Me, Me.Component)
        End If 
        Return m_view

    End Function 

    ' This designer supports the WindowsForms view technology. 
    ReadOnly Property SupportedTechnologies() As ViewTechnology() Implements IRootDesigner.SupportedTechnologies
            Return New ViewTechnology() {ViewTechnology.WindowsForms}
        End Get 
    End Property 

    ' If a LocalizationExtenderProvider has been added, removes the extender provider. 
    Protected Overloads Sub Dispose(ByVal disposing As Boolean)
        ' If an extender has been added, remove it 
        If (extender IsNot Nothing) Then 
            ' Disposes of the extender provider.  The extender  
            ' provider removes itself from the extender provider 
            ' service when it is disposed.
            extender = Nothing 
        End If 
    End Sub 

    ' Empty IDesigner interface property and method implementations 
    Public ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Implements IDesigner.Verbs
            Return Nothing 
        End Get 
    End Property 

    Public ReadOnly Property Component() As System.ComponentModel.IComponent Implements IRootDesigner.Component
            Return Me.component_
        End Get 
    End Property 

    Public Sub DoDefaultAction() Implements IDesigner.DoDefaultAction
    End Sub 

    Public Overloads Sub Dispose() Implements IDisposable.Dispose
    End Sub 

    ' RootDesignerView is a simple control that will be displayed in the designer window. 
    Private Class RootDesignerView
        Inherits Control
        Private m_designer As SampleRootDesigner
        Private comp As IComponent

        Public Sub New(ByVal designer As SampleRootDesigner, ByVal component As IComponent)
            m_designer = designer
            Me.comp = component
            BackColor = Color.Blue
            Font = New Font(FontFamily.GenericMonospace, 12)
        End Sub 

        ' Displays the name of the component and the name of the assembly of the component  
        ' that this root designer is providing support for. 
        Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)

            If (m_designer IsNot Nothing) AndAlso (comp IsNot Nothing) Then 
                ' Draws the name of the component in large letters.
                pe.Graphics.DrawString("Root Designer View", Font, Brushes.Yellow, 8, 4)
                pe.Graphics.DrawString("Design Name  : " + comp.Site.Name, New Font("Arial", 10), Brushes.Yellow, 8, 28)

                ' Uses the site of the component to acquire an ISelectionService and sets the property grid focus to the component. 
                Dim selectionService As ISelectionService = CType(comp.Site.GetService(GetType(ISelectionService)), ISelectionService)
                If (selectionService IsNot Nothing) Then
                    selectionService.SetSelectedComponents(New IComponent() {m_designer.Component})
                End If 
            End If 
        End Sub 
    End Class 

End Class

.NET Framework

Supported in: 1.1
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft