当前位置: 首页>>代码示例>>C#>>正文


C# Globalization.CultureInfo类代码示例

本文整理汇总了C#中System.Globalization.CultureInfo的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo类的具体用法?C# CultureInfo怎么用?C# CultureInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CultureInfo类属于System.Globalization命名空间,在下文中一共展示了CultureInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的System.Globalization.CultureInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。