InfiniteTimeSpanConverter 클래스

정의

문자열과 표준 무한 TimeSpan 값 사이를 변환합니다.

public ref class InfiniteTimeSpanConverter sealed : System::Configuration::ConfigurationConverterBase
public sealed class InfiniteTimeSpanConverter : System.Configuration.ConfigurationConverterBase
type InfiniteTimeSpanConverter = class
    inherit ConfigurationConverterBase
Public NotInheritable Class InfiniteTimeSpanConverter
Inherits ConfigurationConverterBase
상속
InfiniteTimeSpanConverter

예제

다음 코드 예제에서는 클래스를 사용 하는 사용자 지정 섹션 속성을 정의 하는 방법을 보여 있습니다 InfiniteTimeSpanConverter .

사용자 지정 섹션을 구현하는 전체 예제 코드는 클래스를 ConfigurationConverterBase 참조하세요.

[ConfigurationProperty("timeDelay", 
    DefaultValue = "infinite")]
[TypeConverter(typeof(InfiniteTimeSpanConverter))]
public TimeSpan TimeDelay
{
    get
    {
        return (TimeSpan)this["timeDelay"];
    }
    set
    {
        this["timeDelay"] = value;
    }
}

<ConfigurationProperty("timeDelay", _
DefaultValue:="infinite"), _
TypeConverter(GetType(InfiniteTimeSpanConverter))> _
Public Property TimeDelay() As TimeSpan
    Get
        Return CType(Me("timeDelay"), TimeSpan)
    End Get
    Set(ByVal value As TimeSpan)
        Me("timeDelay") = Value
    End Set
End Property

다음 예제 코드는 이전 사용자 지정 섹션 속성에 액세스하는 방법을 보여줍니다.

using System;
using System.IO;
using System.ComponentModel;
using System.Configuration;

namespace Samples.AspNet
{
  
    public sealed class UsingInfiniteTimeSpanConverter
    {
        public static void GetTimeDelay()
        {
            try
            {
                CustomSection section =
                    ConfigurationManager.GetSection("CustomSection")
                    as CustomSection;
                
                Console.WriteLine("timeDelay: {0}", 
                    section.TimeDelay.ToString());
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        public static void SetTimeDelay()
        {
            try
            {
                System.Configuration.Configuration config =
                  ConfigurationManager.OpenExeConfiguration(
                  ConfigurationUserLevel.None);

                CustomSection section =
                    config.Sections.Get("CustomSection")
                    as CustomSection;

                TimeSpan td = 
                    new TimeSpan();

                td =
                    TimeSpan.FromMinutes(
                    DateTime.Now.Minute);

                section.TimeDelay = td;

                section.SectionInformation.ForceSave = true;
                config.Save(ConfigurationSaveMode.Full); 
                config.Save();

                Console.WriteLine("timeDelay: {0}",
                    section.TimeDelay.ToString());
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
Imports System.IO
Imports System.ComponentModel
Imports System.Configuration


NotInheritable Public Class UsingInfiniteTimeSpanConverter
    
    Public Shared Sub GetTimeDelay() 
        Try
            Dim section As CustomSection = _
            ConfigurationManager.GetSection( _
            "CustomSection")
            Console.WriteLine("timeDelay: {0}", _
            section.TimeDelay.ToString())
        Catch e As System.Exception
            Console.WriteLine(e.Message)
        End Try
    
    End Sub
    
    
    Public Shared Sub SetTimeDelay() 
        Try
            Dim config _
            As System.Configuration.Configuration = _
            ConfigurationManager.OpenExeConfiguration( _
            ConfigurationUserLevel.None)
            
            Dim section As CustomSection = _
            config.Sections.Get("CustomSection")
            
            Dim td As New TimeSpan()
            
            td = _
            TimeSpan.FromMinutes( _
            DateTime.Now.Minute)
            
            section.TimeDelay = td
            
            section.SectionInformation.ForceSave = True
            config.Save(ConfigurationSaveMode.Full)
            config.Save()
            
            Console.WriteLine("timeDelay: {0}", _
            section.TimeDelay.ToString())
        Catch e As System.Exception
            Console.WriteLine(e.Message)
        End Try
    
    End Sub
End Class

다음은 이전 예제에서 사용한 구성 발췌입니다.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="CustomSection"
      type="Samples.AspNet.CustomSection,
      ConfigurationConverters,
      Version=1.0.0.0, Culture=neutral,
      PublicKeyToken=null"
      allowDefinition="Everywhere"
      allowExeDefinition="MachineToApplication"
      restartOnExternalChanges="true" />
    </configSections>
    <CustomSection fileName="default.txt" maxIdleTime="90" timeDelay="infinite"/>
</configuration>

설명

이 형식은 다른 모든 구성 변환기 형식과 마찬가지로 구성 파일에 있는 문자열을 관련 강력한 형식의 속성과 변환합니다.

특히 InfiniteTimeSpanConverter 구성 속성에 String 할당된 "infinite" 값을 표준 무한 TimeSpan 으로 변환하고 그 반대로 변환합니다. 무한 TimeSpan 값은 열거형 값으로 MaxValue 표시됩니다.

이 변환기는 속성과 함께 TimeSpan 사용됩니다. 무한 값은 "infinite" 문자열로 유지됩니다.

생성자

Name Description
InfiniteTimeSpanConverter()

InfiniteTimeSpanConverter 클래스의 새 인스턴스를 초기화합니다.

메서드

Name Description
CanConvertFrom(ITypeDescriptorContext, Type)

변환이 허용되는지 여부를 결정합니다.

(다음에서 상속됨 ConfigurationConverterBase)
CanConvertFrom(Type)

이 변환기가 지정된 형식의 개체를 이 변환기의 형식으로 변환할 수 있는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
CanConvertTo(ITypeDescriptorContext, Type)

변환이 허용되는지 여부를 결정합니다.

(다음에서 상속됨 ConfigurationConverterBase)
CanConvertTo(Type)

이 변환기가 개체를 지정된 형식으로 변환할 수 있는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFrom(ITypeDescriptorContext, CultureInfo, Object)

StringTimeSpan로 변환합니다.

ConvertFrom(Object)

지정된 값을 이 변환기의 형식으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFromInvariantString(ITypeDescriptorContext, String)

고정 문화권 및 지정된 컨텍스트를 사용하여 지정된 문자열을 이 변환기의 형식으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFromInvariantString(String)

고정 문화권을 사용하여 지정된 문자열을 이 변환기의 형식으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFromString(ITypeDescriptorContext, CultureInfo, String)

지정된 컨텍스트 및 문화권 정보를 사용하여 지정된 텍스트를 개체로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFromString(ITypeDescriptorContext, String)

지정된 컨텍스트를 사용하여 지정된 텍스트를 개체로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertFromString(String)

지정된 텍스트를 개체로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertTo(ITypeDescriptorContext, CultureInfo, Object, Type)

TimeSpanString로 변환합니다.

ConvertTo(Object, Type)

인수를 사용하여 지정된 값 개체를 지정된 형식으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertToInvariantString(ITypeDescriptorContext, Object)

지정된 컨텍스트를 사용하여 지정된 값을 문화권 고정 문자열 표현으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertToInvariantString(Object)

지정된 값을 문화권 고정 문자열 표현으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertToString(ITypeDescriptorContext, CultureInfo, Object)

지정된 컨텍스트 및 문화권 정보를 사용하여 지정된 값을 문자열 표현으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertToString(ITypeDescriptorContext, Object)

지정된 컨텍스트를 사용하여 지정된 값을 문자열 표현으로 변환합니다.

(다음에서 상속됨 TypeConverter)
ConvertToString(Object)

지정된 값을 문자열 표현으로 변환합니다.

(다음에서 상속됨 TypeConverter)
CreateInstance(IDictionary)

개체에 대한 속성 값 집합이 지정된 경우 Object 다시 만듭니다.

(다음에서 상속됨 TypeConverter)
CreateInstance(ITypeDescriptorContext, IDictionary)

개체에 대한 속성 값 집합이 지정된 경우 지정된 컨텍스트를 사용하여 이 TypeConverter 연결된 형식의 인스턴스를 만듭니다.

(다음에서 상속됨 TypeConverter)
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetConvertFromException(Object)

변환을 수행할 수 없는 경우 throw할 예외를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetConvertToException(Object, Type)

변환을 수행할 수 없는 경우 throw할 예외를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetCreateInstanceSupported()

이 개체의 값을 변경하려면 CreateInstance(IDictionary) 메서드를 호출하여 새 값을 만들어야 하는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetCreateInstanceSupported(ITypeDescriptorContext)

이 개체의 값을 변경하려면 지정된 컨텍스트를 사용하여 새 값을 만들기 위해 CreateInstance(IDictionary) 호출이 필요한지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetProperties(ITypeDescriptorContext, Object, Attribute[])

지정된 컨텍스트 및 특성을 사용하여 값 매개 변수로 지정된 배열 형식에 대한 속성 컬렉션을 반환합니다.

(다음에서 상속됨 TypeConverter)
GetProperties(ITypeDescriptorContext, Object)

지정된 컨텍스트를 사용하여 값 매개 변수로 지정된 배열 형식에 대한 속성 컬렉션을 반환합니다.

(다음에서 상속됨 TypeConverter)
GetProperties(Object)

값 매개 변수로 지정된 배열 형식에 대한 속성 컬렉션을 반환합니다.

(다음에서 상속됨 TypeConverter)
GetPropertiesSupported()

이 개체가 속성을 지원하는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetPropertiesSupported(ITypeDescriptorContext)

지정된 컨텍스트를 사용하여 이 개체가 속성을 지원하는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValues()

이 형식 변환기가 디자인된 데이터 형식의 기본 컨텍스트에서 표준 값 컬렉션을 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValues(ITypeDescriptorContext)

형식 컨텍스트와 함께 제공되는 경우 이 형식 변환기가 디자인된 데이터 형식에 대한 표준 값 컬렉션을 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValuesExclusive()

GetStandardValues() 반환된 표준 값 컬렉션이 단독 목록인지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValuesExclusive(ITypeDescriptorContext)

지정된 컨텍스트를 사용하여 GetStandardValues() 반환된 표준 값 컬렉션이 가능한 값의 단독 목록인지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValuesSupported()

이 개체가 목록에서 선택할 수 있는 표준 값 집합을 지원하는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetStandardValuesSupported(ITypeDescriptorContext)

이 개체가 지정된 컨텍스트를 사용하여 목록에서 선택할 수 있는 표준 값 집합을 지원하는지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
IsValid(ITypeDescriptorContext, Object)

지정된 값 개체가 이 형식 및 지정된 컨텍스트에 대해 유효한지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
IsValid(Object)

지정된 값 개체가 이 형식에 유효한지 여부를 반환합니다.

(다음에서 상속됨 TypeConverter)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
SortProperties(PropertyDescriptorCollection, String[])

속성 컬렉션을 정렬합니다.

(다음에서 상속됨 TypeConverter)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보