FontNamesConverter.ConvertFrom 메서드

정의

글꼴 이름 목록을 나타내는 문자열을 개별 글꼴 이름을 포함하는 문자열 배열로 변환합니다.

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

매개 변수

context
ITypeDescriptorContext

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

culture
CultureInfo

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

value
Object

Object 변환할 원본 문자열을 나타내는 인스턴스입니다.

반품

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

예외

value 가 형식 String이 아닙니다.

예제

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

<%@ 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>

설명

이 메서드를 ConvertFrom 사용하여 글꼴 이름 목록이 포함된 문자열을 개별 이름을 포함하는 문자열 배열로 변환합니다. 문자열의 각 글꼴 이름은 쉼표로 구분해야 합니다. 예를 들어 문자열 "arial, times new roman, verdana"는 문자열 "arial", "times new roman" 및 "verdana"를 포함하는 배열로 변환됩니다. 글꼴 이름의 시작 또는 끝에 있는 공백과 함께 쉼표가 제거됩니다. 글꼴 이름 중간에 있는 공백은 제거되지 않습니다.

메모

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

적용 대상

추가 정보