本文整理汇总了C#中MappingSchema.SetCultureInfo方法的典型用法代码示例。如果您正苦于以下问题:C# MappingSchema.SetCultureInfo方法的具体用法?C# MappingSchema.SetCultureInfo怎么用?C# MappingSchema.SetCultureInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MappingSchema
的用法示例。
在下文中一共展示了MappingSchema.SetCultureInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CultureInfo
public void CultureInfo()
{
var ms = new MappingSchema();
ms.SetCultureInfo(new CultureInfo("ru-RU", false));
Assert.AreEqual("20.01.2012 16:30:40", ms.GetConverter<DateTime,string>()(new DateTime(2012, 1, 20, 16, 30, 40)));
Assert.AreEqual(new DateTime(2012, 1, 20, 16, 30, 40), ms.GetConverter<string,DateTime>()("20.01.2012 16:30:40"));
Assert.AreEqual("100000,999", ms.GetConverter<decimal,string> ()(100000.999m));
Assert.AreEqual(100000.999m, ms.GetConverter<string,decimal> ()("100000,999"));
Assert.AreEqual(100000.999m, ConvertTo<decimal>.From("100000.999"));
Assert.AreEqual("100000,999", ms.GetConverter<double,string> ()(100000.999));
Assert.AreEqual(100000.999, ms.GetConverter<string,double> ()("100000,999"));
}
示例2: CultureInfo
public void CultureInfo()
{
var ms = new MappingSchema();
#if !NETSTANDARD
ms.SetCultureInfo(new CultureInfo("ru-RU", false));
#else
ms.SetCultureInfo(new CultureInfo("ru-RU"));
#endif
Assert.AreEqual("20.01.2012 16:30:40", ms.GetConverter<DateTime,string>()(new DateTime(2012, 1, 20, 16, 30, 40)));
Assert.AreEqual(new DateTime(2012, 1, 20, 16, 30, 40), ms.GetConverter<string,DateTime>()("20.01.2012 16:30:40"));
Assert.AreEqual("100000,999", ms.GetConverter<decimal,string> ()(100000.999m));
Assert.AreEqual(100000.999m, ms.GetConverter<string,decimal> ()("100000,999"));
//Assert.AreEqual(100000.999m, ConvertTo<decimal>.From("100000.999")); this will fail if System Locale is ru-RU
Assert.AreEqual("100000,999", ms.GetConverter<double,string> ()(100000.999));
Assert.AreEqual(100000.999, ms.GetConverter<string,double> ()("100000,999"));
}