コード例 #1
0
        private string ConvertStyleColor(string styleColor)
        {
            var r = new Bridge.Text.RegularExpressions.Regex("^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$");

            var items = r.Exec(styleColor);

            if (items != null && items.Length >= 4)
            {
                styleColor = RgbToHex(items[1], items[2], items[3]);
            }

            return(NormalizeHexStyleColor(styleColor));
        }
コード例 #2
0
ファイル: Guid.cs プロジェクト: night-king/Bridge
        private bool ParseInternal(string input, string format, bool check)
        {
            string r = null;

            if (string.IsNullOrEmpty(input))
            {
                throw new System.ArgumentNullException("input");
            }

            if (string.IsNullOrEmpty(format))
            {
                var m = NonFormat.Exec(input);

                if (m != null)
                {
                    r = m.Slice(1).Join("-").ToLower();
                }
            }
            else
            {
                format = format.ToUpper();

                var p = false;

                if (format == "N")
                {
                    var m = Split.Exec(input);

                    if (m != null)
                    {
                        p     = true;
                        input = m.Slice(1).Join("-");
                    }
                }
                else if (format == "B" || format == "P")
                {
                    var b = format == "B" ? new[] { '{', '}' } : new[] { '(', ')' };

                    if ((input[0] == b[0]) && (input[input.Length - 1] == b[1]))
                    {
                        p     = true;
                        input = input.Substr(1, input.Length - 2);
                    }
                }
                else
                {
                    p = true;
                }

                if (p && input.Match(Valid) != null)
                {
                    r = input.ToLower();
                }
            }

            if (r != null)
            {
                FromString(r);
                return(true);
            }

            if (check)
            {
                throw new System.FormatException("input is not in a recognized format");
            }

            return(false);
        }