Szerkesztés

Megosztás a következőn keresztül:


CultureAndRegionInfoBuilder Class

Definition

Defines a custom culture that is new or based on another culture and country/region. The custom culture can be installed on a computer and subsequently used by any application that is running on that computer. This class cannot be inherited.

public ref class CultureAndRegionInfoBuilder sealed
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class CultureAndRegionInfoBuilder
[<System.Runtime.InteropServices.ComVisible(false)>]
type CultureAndRegionInfoBuilder = class
Public NotInheritable Class CultureAndRegionInfoBuilder
Inheritance
CultureAndRegionInfoBuilder
Attributes

Examples

The following example defines a custom ru-US culture that represents the Russian language in the United States. The example defines the custom culture by loading settings from the Russian (Russia) CultureInfo object and the U.S. RegionInfo object, and then sets a number of CultureAndRegionInfoBuilder properties. The example registers the custom culture, and then instantiates it and makes it the current culture.

using System;
using System.Globalization;
using System.Threading;

public class Example
{
   public static void Main()
   {
      // Create a custom culture for ru-US.
      CultureAndRegionInfoBuilder car1 = new CultureAndRegionInfoBuilder("ru-US",
                                             CultureAndRegionModifiers.None);
      car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"));
      car1.LoadDataFromRegionInfo(new RegionInfo("en-US"));

      car1.CultureEnglishName = "Russian (United States)";
      car1.CultureNativeName = "русский (США)";
      car1.CurrencyNativeName = "Доллар (США)";
      car1.RegionNativeName = "США";

      // Register the culture.
      try {
         car1.Register();
      }
      catch (InvalidOperationException) {
         // Swallow the exception: the culture already is registered.
      }

      // Use the custom culture.
      CultureInfo ci = CultureInfo.CreateSpecificCulture("ru-US");
      Thread.CurrentThread.CurrentCulture = ci;
      Console.WriteLine("Current Culture: {0}",
                        Thread.CurrentThread.CurrentCulture.Name);
      Console.WriteLine("Writing System: {0}",
                        Thread.CurrentThread.CurrentCulture.TextInfo);
   }
}
// The example displays the following output:
//     Current Culture: ru-US
//     Writing System: TextInfo - ru-US
Imports System.Globalization
Imports System.Threading

Module Example
   Public Sub Main()
      ' Create a custom culture for ru-US.
      Dim car1 As New CultureAndRegionInfoBuilder("ru-US", CultureAndRegionModifiers.None)
      car1.LoadDataFromCultureInfo(CultureInfo.CreateSpecificCulture("ru-RU"))
      car1.LoadDataFromRegionInfo(New RegionInfo("en-US"))
      
      car1.CultureEnglishName = "Russian (United States)"
      car1.CultureNativeName = "русский (США)"
      car1.CurrencyNativeName = "Доллар (США)"
      car1.RegionNativeName = "США"

      ' Register the culture.
      Try
         car1.Register()
      Catch e As InvalidOperationException
         ' Swallow the exception: the culture already is registered.
      End Try
      
      ' Use the custom culture.
      Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("ru-US")
      Thread.CurrentThread.CurrentCulture = ci
      Console.WriteLine("Current Culture: {0}", 
                        Thread.CurrentThread.CurrentCulture.Name)
      Console.WriteLine("Writing System: {0}", 
                        Thread.CurrentThread.CurrentCulture.TextInfo)
   End Sub
End Module
' The example displays the following output:
'     Current Culture: ru-US
'     Writing System: TextInfo - ru-US

Remarks

For more information about this API, see Supplemental API remarks for CultureAndRegionInfoBuilder.

Constructors

CultureAndRegionInfoBuilder(String, CultureAndRegionModifiers)

Initializes a new instance of the CultureAndRegionInfoBuilder class.

Properties

AvailableCalendars

Gets or sets an array of calendars that are supported by this CultureAndRegionInfoBuilder object.

CompareInfo

Gets or sets the CompareInfo object that defines how to compare strings for the culture.

ConsoleFallbackUICulture

Gets or sets an alternate user interface culture suitable for console applications when the default graphic user interface culture is inappropriate.

CultureEnglishName

Gets or sets the culture name in English.

CultureName

Gets the name of the culture being created.

CultureNativeName

Gets or sets the culture name in the format and language that the culture is set to display.

CultureTypes

Gets the CultureTypes value that describes the culture represented by the current CultureAndRegionInfoBuilder object.

CurrencyEnglishName

Gets or sets the name, in English, of the currency used in the country/region represented by the current CultureAndRegionInfoBuilder object.

CurrencyNativeName

Gets or sets the native name of the currency used in the country/region represented by the current CultureAndRegionInfoBuilder object.

GeoId

Gets or sets a unique identification number for a geographical region, country, city, or location.

GregorianDateTimeFormat

Gets or sets a DateTimeFormatInfo object that defines the format of dates and times according to the Gregorian calendar.

IetfLanguageTag

Gets or sets a culture name formatted according to the RFC 4646 standard, "Tags for the Identification of Languages."

IsMetric

Gets or sets a value indicating whether the country/region uses the metric system for measurements.

ISOCurrencySymbol

Gets or sets the three-character ISO 4217 currency symbol associated with the country/region.

IsRightToLeft

Gets or sets the predominant direction of lines of text in the writing system associated with the current CultureAndRegionInfoBuilder object.

KeyboardLayoutId

Gets or sets the active input locale identifier.

LCID

Gets the culture identifier for the current CultureAndRegionInfoBuilder object.

NumberFormat

Gets or sets a NumberFormatInfo object that defines the culturally appropriate format of displaying numbers, currency, and percentage.

Parent

Gets or sets the CultureInfo object that represents the parent culture of the current custom culture.

RegionEnglishName

Gets or sets the full name of the country/region in English.

RegionName

Gets the name of the country/region for the current CultureAndRegionInfoBuilder object.

RegionNativeName

Gets or sets the full name of the country/region as known by the people of this custom culture.

TextInfo

Gets or sets the TextInfo object that defines the writing system associated with this custom culture.

ThreeLetterISOLanguageName

Gets or sets the ISO 639-2 three-letter code for the language of this custom culture.

ThreeLetterISORegionName

Gets or sets the three-letter code defined in ISO 3166 for the country/region.

ThreeLetterWindowsLanguageName

Gets or sets the three-letter code for the language as defined in the Windows API.

ThreeLetterWindowsRegionName

Gets or sets the three-letter code assigned by Windows to the country/region represented by the current custom culture.

TwoLetterISOLanguageName

Gets or sets the ISO 639-1 two-letter code for the language of the current CultureInfo object.

TwoLetterISORegionName

Gets or sets the two-letter code defined in ISO 3166 for the country/region.

Methods

CreateFromLdml(String)

Reconstitutes a CultureAndRegionInfoBuilder object from a specified XML file that contains a representation of the object.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
LoadDataFromCultureInfo(CultureInfo)

Sets the properties of the current CultureAndRegionInfoBuilder object with the corresponding properties of the specified CultureInfo object.

LoadDataFromRegionInfo(RegionInfo)

Sets the properties of the current CultureAndRegionInfoBuilder object with the corresponding properties of the specified RegionInfo object.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Register()

Persists the current CultureAndRegionInfoBuilder object as a custom culture on the local computer and makes that culture available to applications. Requires administrative privileges.

Save(String)

Writes an XML representation of the current CultureAndRegionInfoBuilder object to the specified file.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
Unregister(String)

Deletes a custom culture from the local computer.

Applies to