示例#1
0
 /// <summary>
 /// Creates the calendar.
 /// </summary>
 /// <param name="cultureID">The culture ID.</param>
 /// <returns>Returns the calendar.</returns>
 public static Calendar CreateCalendar(string cultureID)
 {
     try
     {
         return(CreateCalendar(NumberHelper.ParseHexString(cultureID)));
     }
     catch
     {
         return(new GregorianCalendar());
     }
 }
示例#2
0
 /// <summary>
 /// Creates the culture information.
 /// </summary>
 /// <param name="cultureID">The culture ID.</param>
 /// <returns>Returns the culture information.</returns>
 public static CultureInfo CreateCultureInfo(string cultureID)
 {
     try
     {
         return(CreateCultureInfo(NumberHelper.ParseHexString(cultureID)));
     }
     catch
     {
         return(CultureInfo.CurrentCulture);
     }
 }
示例#3
0
文件: ColorHelper.cs 项目: Daoting/dt
 /// <summary>
 /// Converts a color from a string value.
 /// </summary>
 /// <param name="color">The color (#ff223344).</param>
 /// <returns>Returns the color.</returns>
 public static Windows.UI.Color?FromStringValue(string color)
 {
     if ((color != null) && color.StartsWith(((char)DefaultTokens.Sharp).ToString()))
     {
         try
         {
             int num = NumberHelper.ParseHexString(color.TrimStart(new char[] { DefaultTokens.Sharp }));
             return(new Windows.UI.Color?(Windows.UI.Color.FromArgb((byte)((num & 0xff000000L) >> 0x18), (byte)((num & 0xff0000) >> 0x10), (byte)((num & 0xff00) >> 8), (byte)(num & 0xff))));
         }
         catch
         {
         }
     }
     return(null);
 }
示例#4
0
        /// <summary>
        /// Creates a new locale format with the specified token.
        /// </summary>
        /// <param name="token">The string expression for the format.</param>
        public LocaleIDFormatPart(string token) : base(token)
        {
            this.locateID = -1;
            if (token == null)
            {
                throw new ArgumentNullException("token");
            }
            if (token == string.Empty)
            {
                throw new FormatException(ResourceStrings.FormatterIllegaTokenError);
            }
            this.content = DefaultTokens.TrimSquareBracket(token);
            string content = this.content;

            if ((content == null) || (content == string.Empty))
            {
                throw new FormatException(ResourceStrings.FormatterIllegaTokenError);
            }
            if (!DefaultTokens.IsEquals(content[0], DefaultTokens.Dollar, false))
            {
                throw new FormatException(ResourceStrings.FormatterIllegaTokenError);
            }
            content = content.Remove(0, 1);
            int index = content.IndexOf(DefaultTokens.HyphenMinus);

            if (index > -1)
            {
                this.currencySymbol = content.Substring(0, index);
                content             = content.Remove(0, index);
            }
            else
            {
                this.currencySymbol = content;
                return;
            }
            if (!DefaultTokens.IsEquals(content[0], DefaultTokens.HyphenMinus, false))
            {
                throw new FormatException(ResourceStrings.FormatterIllegaTokenError);
            }
            content = content.Remove(0, 1);
            if (content.Length <= 0)
            {
                throw new FormatException(ResourceStrings.FormatterIllegaTokenError);
            }
            this.locateID = NumberHelper.ParseHexString(content);
        }