FontNamesConverter.ConvertTo 메서드

정의

개별 글꼴 이름을 포함하는 문자열 배열의 글꼴 이름 목록을 나타내는 문자열을 만듭니다.

public:
 override System::Object ^ ConvertTo(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value, Type ^ destinationType);
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType);
override this.ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj
Public Overrides Function ConvertTo (context As ITypeDescriptorContext, culture As CultureInfo, value As Object, destinationType As Type) As Object

매개 변수

context
ITypeDescriptorContext

ITypeDescriptorContext 형식 변환기의 컨텍스트에 대한 정보를 제공하는 개체입니다. 이 매개 변수는 이 메서드에서 사용되지 않습니다. 이 메서드의 이후 버전용으로 예약되어 있습니다. 필요에 따라 이 매개 변수에 null 전달할 수 있습니다.

culture
CultureInfo

CultureInfo 언어, 달력 시스템 등과 같은 문화권에 대한 정보를 나타내는 개체입니다. 이 매개 변수는 이 메서드에서 사용되지 않습니다. 이 메서드의 이후 버전용으로 예약되어 있습니다. 필요에 따라 이 매개 변수에 null 전달할 수 있습니다.

value
Object

변환할 문자열의 원본 배열을 나타내는 개체입니다.

destinationType
Type

Object 변환할 데이터 형식을 나타내는 인스턴스 개체입니다. 이 매개 변수는 형식 String이어야 합니다.

반품

Object 글꼴 이름 목록을 포함하는 문자열을 나타내는 인스턴스입니다.

예외

destinationType 가 형식 String이 아닙니다.

예제

다음 코드 예제에서는 개별 이름을 포함 하는 문자열의 배열을 글꼴 이름 목록을 포함 하는 단일 문자열로 변환 하는 메서드를 사용 ConvertTo 하는 방법을 보여 줍니다.

<%@ Page Language="C#" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>FontNamesConverter Example</title>
<script language="C#" runat="server">

      void Page_Load(Object sender, EventArgs e) 
      {

         // Declare local variables.
         System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en");
         System.ComponentModel.ITypeDescriptorContext context = null;
         Object names; 
         Object name_string;

         // Create FontNamesConverter object.
         FontNamesConverter fontconverter = new FontNamesConverter();

         // Create original list of fonts.
         string font_list = "arial, times new roman, verdana";

         // Check for type compatibility.
         if (fontconverter.CanConvertFrom(context, typeof(string)))
         {

            // Display original string.
            Label1.Text = "Original String :" + "<br /><br />" + font_list;

            // Convert string to array to strings and display results.
            names = fontconverter.ConvertFrom(context, culture, font_list);
            Label2.Text = "Converted to Array of Strings : " + "<br /><br />";
            foreach (string name_element in (string[])names)
            {
               Label2.Text += name_element + "<br />";
            }

            // Convert array of strings back to a string and display results.
            name_string = fontconverter.ConvertTo(context, culture, names, typeof(string)); 
            Label3.Text = "Converted back to String :" + "<br /><br />" + (string)name_string;

         }
          
      }

   </script>

</head>
<body>

   <h3>FontNamesConverter Example</h3>
   <br />

   <form id="form1" runat="server">
        
      <asp:Label id="Label1" runat="server"/>
      <br /><hr />
      <asp:Label id="Label2" runat="server"/>
      <br /><hr />
      <asp:Label id="Label3" runat="server"/>
        
   </form>

</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>FontNamesConverter Example</title>
<script language="VB" runat="server">
    Sub Page_Load(sender As Object, e As EventArgs)
        
        ' Declare local variables.
        Dim culture As New System.Globalization.CultureInfo("en")
        Dim context As System.ComponentModel.ITypeDescriptorContext = Nothing
        Dim names As Object
        Dim name_string As Object
        
        ' Create FontNamesConverter object.
        Dim fontconverter As New FontNamesConverter()
        
        ' Create original list of fonts.
        Dim font_list As String = "arial, times new roman, verdana"
        
        ' Check for type compatibility.
        If fontconverter.CanConvertFrom(context, GetType(String)) Then
            
            ' Display original string.
            Label1.Text = "Original String :" & "<br /><br />" & font_list
            
            ' Convert string to array to strings and display results.
            names = fontconverter.ConvertFrom(context, culture, font_list)
            Label2.Text = "Converted to Array of Strings : " & "<br /><br />"
            Dim name_element As String
            For Each name_element In CType(names, String())
                Label2.Text &= name_element & "<br />"
            Next name_element
            
            ' Convert array of strings back to a string and display results.
            name_string = fontconverter.ConvertTo(context, culture, names, _
                GetType(String))
            Label3.Text = "Converted back to String :" & "<br /><br />" & _
                CType(name_string, String)
        End If 
    End Sub 'Page_Load
  </script>

</head>
<body>

   <h3>FontNamesConverter Example</h3>
   <br />

   <form id="form1" runat="server">
        
      <asp:Label id="Label1" runat="server"/>
      <br /><hr />
      <asp:Label id="Label2" runat="server"/>
      <br /><hr />
      <asp:Label id="Label3" runat="server"/>
        
   </form>

</body>
</html>

설명

메서드를 ConvertTo 사용하여 개별 글꼴 이름을 포함하는 문자열 배열을 이름 목록을 포함하는 단일 문자열로 변환합니다. 예를 들어 문자열 "arial", "times new roman" 및 "verdana"가 포함된 배열은 문자열 "arial,times new roman,verdana"로 변환됩니다. 공백 없이 글꼴 이름 사이에 쉼표가 자동으로 삽입됩니다.

메모

이 변환기는 데이터 형식으로 string 만 변환할 수 있습니다. 매개 변수는 destinationType 형식 String이어야 합니다.

메모

context 메서드 버전에서는 매개 변수와 culture 매개 변수가 사용되지 않으며 이후 버전의 메서드용으로 예약되어 있습니다. 필요에 따라 이러한 매개 변수에 null 전달할 수 있습니다.

적용 대상

추가 정보