當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。