本文整理汇总了C#中System.Globalization.CultureInfo类的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo类的具体用法?C# CultureInfo怎么用?C# CultureInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CultureInfo类属于System.Globalization命名空间,在下文中一共展示了CultureInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var flag = false;
if (value is bool)
{
flag = (bool)value;
}
else if (value is bool?)
{
var nullable = (bool?)value;
flag = nullable.GetValueOrDefault();
}
if (parameter != null)
{
if (bool.Parse((string)parameter))
{
flag = !flag;
}
}
if (flag)
{
return "/Resources/Images/License_Valid.png";
}
else
{
return "/Resources/Images/License_Invalid.png";
}
}
开发者ID:danimal,项目名称:keys,代码行数:28,代码来源:BooleanToImageConverter.cs
示例2: ConvertFrom
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
var vs = ((string)value).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
return vs.Select(v => v.Trim('"')).ToList();
}
return base.ConvertFrom(context, culture, value);
}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:7,代码来源:CsvConverter.cs
示例3: ConvertTo
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (context == null)
return null;
var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
return p != null ? p.GetName (value) : null;
}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs
示例4: Ctor_CultureInfo
public static void Ctor_CultureInfo(object a, object b, int expected)
{
var culture = new CultureInfo("en-US");
var comparer = new Comparer(culture);
Assert.Equal(expected, Math.Sign(comparer.Compare(a, b)));
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:7,代码来源:ComparerTests.cs
示例5: Convert
/// <summary>
/// Converts the source value to a target value.
/// </summary>
/// <param name="value">The source value to convert.</param>
/// <param name="targetType">The type of the target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>
/// A converted value. If the method returns null, the valid null value is used.
/// </returns>
/// <remarks>
/// This method will only be called if the mode of the <see cref="SingleSourceBinding"/> is either <see cref="BindingMode.TwoWay"/>
/// or <see cref="BindingMode.OneWayToTarget"/>.
/// </remarks>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof (string))
return value;
return ((DateTime) value).ToString("d", culture);
}
开发者ID:tfreitasleal,项目名称:MvvmFx,代码行数:21,代码来源:DateTimeToDateConverter.cs
示例6: TimeFormatter
// ----------------------------------------------------------------------
public TimeFormatter( CultureInfo culture = null,
string contextSeparator = "; ", string startEndSeparator = " - ",
string durationSeparator = " | ",
string dateTimeFormat = null,
string shortDateFormat = null,
string longTimeFormat = null,
string shortTimeFormat = null,
DurationFormatType durationType = DurationFormatType.Compact,
bool useDurationSeconds = false,
bool useIsoIntervalNotation = false)
{
if ( culture == null )
{
culture = CultureInfo.CurrentCulture;
}
this.culture = culture;
listSeparator = culture.TextInfo.ListSeparator;
this.contextSeparator = contextSeparator;
this.startEndSeparator = startEndSeparator;
this.durationSeparator = durationSeparator;
this.dateTimeFormat = dateTimeFormat;
this.shortDateFormat = shortDateFormat;
this.longTimeFormat = longTimeFormat;
this.shortTimeFormat = shortTimeFormat;
this.durationType = durationType;
this.useDurationSeconds = useDurationSeconds;
this.useIsoIntervalNotation = useIsoIntervalNotation;
}
开发者ID:jwg4,项目名称:date-difference,代码行数:29,代码来源:TimeFormatter.cs
示例7: ConvertBack
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return TimeConverter.ConvertTimeToDouble(value, targetType, parameter, culture);
/*if (targetType == typeof(Double))
{
TimePart timePart = TimeConverter.GetTimePart(parameter, culture);
if (value is TimeSpan)
{
return TimeConverter.TimeSpanToDouble((TimeSpan)value, timePart);
}
if (value is Duration)
{
return TimeConverter.DurationToDouble((Duration)value, timePart);
}
if (value is DateTime)
{
return TimeConverter.DateTimeToDouble((DateTime)value, timePart);
}
}
return DependencyProperty.UnsetValue;*/
}
开发者ID:CuteITGuy,项目名称:CB.Xaml,代码行数:25,代码来源:DoubleToTimeConverter.cs
示例8: ConvertSimple
private object ConvertSimple(Type typeToConvertTo, object value, CultureInfo cultureInfo)
{
if (typeToConvertTo.IsEnum && value is string)
return Enum.Parse(typeToConvertTo, (string)value, true);
return System.Convert.ChangeType(value, typeToConvertTo, cultureInfo);
}
开发者ID:KimmoKer,项目名称:SpecFlow,代码行数:7,代码来源:StepArgumentTypeConverter.cs
示例9: AuthorizationParameters
/// <summary>
/// </summary>
/// <param name="culture">Текущие сведения о языке и региональных параметрах</param>
/// <param name="authUri">Url авторизации</param>
/// <param name="blankUri">Url на который возвращаются данные авторизации</param>
/// <param name="availableHostNames">Доступные имена хостов в браузере. Если NulL, то доступен переход на любой хост</param>
public AuthorizationParameters(CultureInfo culture, Uri authUri, Uri blankUri, IEnumerable<string> availableHostNames = null)
{
_culture = culture;
_authUri = authUri;
_blankUri = blankUri;
_availableHostNames = availableHostNames;
}
开发者ID:ukionik,项目名称:VDesktopeNew,代码行数:13,代码来源:AuthorizationParameters.cs
示例10: ConvertBack
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
RepeatType repeatType = RepeatType.NotRepeated;
if (value is int)
{
switch ((int)value)
{
case 0:
repeatType = RepeatType.NotRepeated;
break;
case 1:
repeatType = RepeatType.Daily;
break;
case 2:
repeatType = RepeatType.Weekly;
break;
case 3:
repeatType = RepeatType.Monthly;
break;
case 4:
repeatType = RepeatType.Yearly;
break;
default:
break;
}
}
return repeatType;
}
开发者ID:SalmanRafiq,项目名称:MetroCalendar,代码行数:29,代码来源:RepeatTypeToIntegerConverter.cs
示例11: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Visibility.Collapsed;
bool visibility = (bool)value;
return visibility ? Visibility.Collapsed : Visibility.Visible;
}
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:7,代码来源:ReverseBoolVisibilityConverter.cs
示例12: Convert
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
ScanStatus s1 = (ScanStatus)value;
ScanStatus s2 = (ScanStatus)parameter;
return s1 == s2 ? Visibility.Visible : Visibility.Collapsed;
}
开发者ID:nullkuhl,项目名称:fdu-dev,代码行数:7,代码来源:PropertyEqualsToVisibilityConverter.cs
示例13: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int index = value is int ? (int)value : 0;
int type = parameter is string ? Int32.Parse((string)parameter) : 0;
switch (type)
{
case Background:
if (index % 2 == 0)
{
return MotionFullItemBackgroundEven;
}
return MotionFullItemBackgroundOdd;
case TopSeperator:
if (index % 2 == 0)
{
return MotionFullItemTopSeperatorEven;
}
return MotionFullItemTopSeperatorOdd;
case BottomSeperator:
if (index % 2 == 0)
{
return MotionFullItemBottomSeperatorEven;
}
return MotionFullItemBottomSeperatorOdd;
default:
Debug.Assert(type != 0, "Null type");
return null;
}
}
开发者ID:huucp,项目名称:tuneRobo,代码行数:30,代码来源:IndexToColorConverter.cs
示例14: Test1
public void Test1()
{
string[] edays = {
"\u661F\u671F\u65E5",
"\u661F\u671F\u4E00",
"\u661F\u671F\u4E8C",
"\u661F\u671F\u4E09",
"\u661F\u671F\u56DB",
"\u661F\u671F\u4E94",
"\u661F\u671F\u516D"
};
string[] emonths = GetMonthNames();
DateTimeFormatInfo dtfi = new CultureInfo("zh-TW").DateTimeFormat;
dtfi.Calendar = new TaiwanCalendar();
// Actual Day Names and Month Names for TaiwanCalendar
string[] adays = dtfi.DayNames;
for (int i = 0; i < edays.Length; i++)
{
Assert.Equal(edays[i], adays[i]);
}
string[] amonths = dtfi.MonthNames;
for (int i = 0; i < edays.Length; i++)
{
Assert.Equal(emonths[i], amonths[i]);
}
}
开发者ID:noahfalk,项目名称:corefx,代码行数:30,代码来源:TaiwanCalendarDaysAndMonths.cs
示例15: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// Parse value into equation and remove spaces
var mathEquation = parameter as string;
mathEquation = mathEquation.Replace(" ", "");
mathEquation = mathEquation.Replace("@VALUE", value.ToString());
// Validate values and get list of numbers in equation
var numbers = new List<double>();
double tmp;
foreach (string s in mathEquation.Split(_allOperators))
{
if (s != string.Empty)
{
if (double.TryParse(s, out tmp))
{
numbers.Add(tmp);
}
else
{
// Handle Error - Some non-numeric, operator, or grouping character found in string
throw new InvalidCastException();
}
}
}
// Begin parsing method
EvaluateMathString(ref mathEquation, ref numbers, 0);
// After parsing the numbers list should only have one value - the total
return numbers[0];
}
开发者ID:nicbet,项目名称:MahApps.Metro,代码行数:33,代码来源:MathConverter.cs
示例16: Convert
public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
{
if ( value == null ) return null;
if ( value.GetType() == typeof( System.Net.IPAddress ) ) return ( ( System.Net.IPAddress ) value ).ToString();
return String.Empty;
}
开发者ID:AluhutSecurity,项目名称:1033S,代码行数:7,代码来源:IPAddressToStringConverter.cs
示例17: CreateTaskByTable
public static Task CreateTaskByTable(DataTable dt)
{
Task task = null;
try
{
task = new Task();
task.TaskNo = (dt.Rows[0]["TaskNo"] == null ? "" : dt.Rows[0]["TaskNo"].ToString());
task.BatchNo = (dt.Rows[0]["BatchNo"] == null ? "" : dt.Rows[0]["BatchNo"].ToString());
task.ItemNo = (dt.Rows[0]["ItemNo"] == null ? "" : dt.Rows[0]["ItemNo"].ToString());
task.ItemName = (dt.Rows[0]["ItemName"] == null ? "" : dt.Rows[0]["ItemName"].ToString());
task.Sn = (dt.Rows[0]["Sn"] == null ? "" : dt.Rows[0]["Sn"].ToString());
task.PV = (dt.Rows[0]["PV"] == null ? 0 : int.Parse(dt.Rows[0]["PV"].ToString()));
task.Result = (dt.Rows[0]["Result"] == null ? 0 : int.Parse(dt.Rows[0]["Result"].ToString()));
task.redundantVaue = (dt.Rows[0]["RedundantVaue"] == null ? 0 : int.Parse(dt.Rows[0]["RedundantVaue"].ToString()));
IFormatProvider ifp = new CultureInfo("zh-CN", true);
if (dt.Rows[0]["StartTime"] != null)
{
DateTime.TryParseExact(dt.Rows[0]["StartTime"].ToString(), DateTimeFormat2, ifp, DateTimeStyles.None, out task.StartTime);
}
if (dt.Rows[0]["CompleteTime"] != null)
{
DateTime.TryParseExact(dt.Rows[0]["CompleteTime"].ToString(), DateTimeFormat2, ifp, DateTimeStyles.None, out task.CompleteTime);
}
return task;
}
catch (Exception ex)
{
Program.WriteErrorLog("CreateTaskByTable", ex);
return task;
}
}
开发者ID:wxgb9801,项目名称:Measurer,代码行数:31,代码来源:Task.cs
示例18: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var format = parameter as string;
if (format == "B")
return ConvertUnit(value, CommonLocale.B, 1024, "", CommonLocale.ki, CommonLocale.Mi, CommonLocale.Gi);
return value;
}
开发者ID:systemmetaphor,项目名称:BlueDwarf,代码行数:7,代码来源:UnitConverter.cs
示例19: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return TimeConverter.ConvertDoubleToTime(value, targetType, parameter, culture);
/*if (value is Double)
{
Double d = (Double)value;
TimePart timePart = TimeConverter.GetTimePart(parameter, culture);
if (targetType == typeof(TimeSpan))
{
return TimeConverter.DoubleToTimeSpan(d, timePart);
}
if (targetType == typeof(Duration))
{
return TimeConverter.DoubleToDuration(d, timePart);
}
if (targetType == typeof(DateTime))
{
return TimeConverter.DoubleToDateTime(d, timePart);
}
}
return DependencyProperty.UnsetValue;*/
}
开发者ID:CuteITGuy,项目名称:CB.Xaml,代码行数:26,代码来源:DoubleToTimeConverter.cs
示例20: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is bool)) return DependencyProperty.UnsetValue;
bool visible = ((bool)value) ^ VisibleWhenFalse;
return visible ? Visibility.Visible : Visibility.Collapsed;
}
开发者ID:martinsuchan,项目名称:wpdev.samples,代码行数:7,代码来源:BoolToVisibilityConverter.cs
注:本文中的System.Globalization.CultureInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论