本文整理匯總了C#中System.Configuration.InfiniteTimeSpanConverter類的典型用法代碼示例。如果您正苦於以下問題:C# InfiniteTimeSpanConverter類的具體用法?C# InfiniteTimeSpanConverter怎麽用?C# InfiniteTimeSpanConverter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
InfiniteTimeSpanConverter類屬於System.Configuration命名空間,在下文中一共展示了InfiniteTimeSpanConverter類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: return
[ConfigurationProperty("timeDelay",
DefaultValue = "infinite")]
[TypeConverter(typeof(InfiniteTimeSpanConverter))]
public TimeSpan TimeDelay
{
get
{
return (TimeSpan)this["timeDelay"];
}
set
{
this["timeDelay"] = value;
}
}
示例2: GetTimeDelay
//引入命名空間
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);
}
}
}
}