Пример #1
0
        public static PointCollection Parse(string source)
        {
            var result = new PointCollection();

            if (source != null)
            {
                IFormatProvider formatProvider = CultureInfo.InvariantCulture;
                char[]          separator      = new char[2] {
                    TokenizerHelper.GetNumericListSeparator(formatProvider), ' '
                };
                string[] split = source.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                // Points count needs to be an even number
                if (split.Length % 2 == 1)
                {
                    throw new FormatException($"'{source}' is not an eligible value for a {typeof(PointCollection)}.");
                }

                for (int i = 0; i < split.Length; i += 2)
                {
                    result.Add(
                        new Point(
                            Convert.ToDouble(split[i], formatProvider),
                            Convert.ToDouble(split[i + 1], formatProvider)
                            )
                        );
                }
            }

            return(result);
        }
Пример #2
0
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (format != null)
            {
                char     numericListSeparator = TokenizerHelper.GetNumericListSeparator(provider);
                string[] strArrays            = new string[] { "sc#{1:", format, "}{0} {2:", format, "}{0} {3:", format, "}{0} {4:", format, "}" };
                string   str      = string.Concat(strArrays);
                object[] objArray = new object[] { numericListSeparator, this.innerRgbColor.A, this.innerRgbColor.R, this.innerRgbColor.G, this.innerRgbColor.B };
                stringBuilder.AppendFormat(provider, str, objArray);
            }
            else
            {
                object[] objArray1 = new object[] { this.innerRgbColor.A };
                stringBuilder.AppendFormat(provider, "#{0:X2}", objArray1);
                object[] objArray2 = new object[] { this.innerRgbColor.R };
                stringBuilder.AppendFormat(provider, "{0:X2}", objArray2);
                object[] objArray3 = new object[] { this.innerRgbColor.G };
                stringBuilder.AppendFormat(provider, "{0:X2}", objArray3);
                object[] objArray4 = new object[] { this.innerRgbColor.B };
                stringBuilder.AppendFormat(provider, "{0:X2}", objArray4);
            }
            return(stringBuilder.ToString());
        }
Пример #3
0
        /// <summary>
        /// Implements ToString.
        /// </summary>
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            char numericListSeparator = TokenizerHelper.GetNumericListSeparator(provider);

            provider = provider ?? CultureInfo.InvariantCulture;
            return(string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}", new object[] { numericListSeparator, _x, _y }));
        }
Пример #4
0
        /// <summary>
        /// Creates a string representation of this object based on the format string
        /// and IFormatProvider passed in.
        /// If the provider is null, the CurrentCulture is used.
        /// See the documentation for IFormattable for more information.
        /// </summary>
        /// <returns>
        /// A string representation of this object.
        /// </returns>
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            StringBuilder sb = new StringBuilder();

            if (format == null)
            {
                sb.Append(string.Format(provider, "#{0:X2}", this.sRgbColor.a));
                sb.Append(string.Format(provider, "{0:X2}", this.sRgbColor.r));
                sb.Append(string.Format(provider, "{0:X2}", this.sRgbColor.g));
                sb.Append(string.Format(provider, "{0:X2}", this.sRgbColor.b));
            }
            else
            {
                // Helper to get the numeric list separator for a given culture.
                char separator = TokenizerHelper.GetNumericListSeparator(provider);

                sb.Append(
                    string.Format(
                        provider,
                        "sc#{1:" + format + "}{0} {2:" + format + "}{0} {3:" + format + "}{0} {4:" + format + "}",
                        separator, sRgbColor.a, sRgbColor.r, sRgbColor.g, sRgbColor.b
                        )
                    );
            }

            return(sb.ToString());
        }
        // Token: 0x0600540E RID: 21518 RVA: 0x00174C2C File Offset: 0x00172E2C
        internal static string ToString(VirtualizationCacheLength cacheLength, CultureInfo cultureInfo)
        {
            char          numericListSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
            StringBuilder stringBuilder        = new StringBuilder(26);

            stringBuilder.Append(cacheLength.CacheBeforeViewport.ToString(cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(cacheLength.CacheAfterViewport.ToString(cultureInfo));
            return(stringBuilder.ToString());
        }
Пример #6
0
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            if (IsEmpty)
            {
                return("Empty");
            }
            char numericListSeparator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}", new object[] { numericListSeparator, x, y, width, height }));
        }
Пример #7
0
        private string ConvertToString(string?format, IFormatProvider?provider)
        {
            // Helper to get the numeric list separator for a given culture.
            char separator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider,
                                 "{1:" + format + "}{0}{2:" + format + "}",
                                 separator,
                                 _x,
                                 _y));
        }
Пример #8
0
        public string ConvertToString(string format, IFormatProvider provider)
        {
            if (IsEmpty)
            {
                return("Empty");
            }

            char listSeparator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}", listSeparator, xMin, yMin, width, height));
        }
Пример #9
0
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            if (IsEmpty)
            {
                return("Empty");
            }
            char numericListSeparator = TokenizerHelper.GetNumericListSeparator(provider);

            provider = provider ?? CultureInfo.InvariantCulture;
            // ReSharper disable FormatStringProblem
            return(string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}", new object[] { numericListSeparator, _x, _y, _width, _height }));
            // ReSharper restore FormatStringProblem
        }
Пример #10
0
        // Token: 0x06000C55 RID: 3157 RVA: 0x0002DE6C File Offset: 0x0002C06C
        internal static string ToString(Thickness th, CultureInfo cultureInfo)
        {
            char          numericListSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
            StringBuilder stringBuilder        = new StringBuilder(64);

            stringBuilder.Append(LengthConverter.ToString(th.Left, cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(LengthConverter.ToString(th.Top, cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(LengthConverter.ToString(th.Right, cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(LengthConverter.ToString(th.Bottom, cultureInfo));
            return(stringBuilder.ToString());
        }
Пример #11
0
        // Token: 0x06000380 RID: 896 RVA: 0x0000A0D0 File Offset: 0x000082D0
        internal static string ToString(CornerRadius cr, CultureInfo cultureInfo)
        {
            char          numericListSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
            StringBuilder stringBuilder        = new StringBuilder(64);

            stringBuilder.Append(cr.TopLeft.ToString(cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(cr.TopRight.ToString(cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(cr.BottomRight.ToString(cultureInfo));
            stringBuilder.Append(numericListSeparator);
            stringBuilder.Append(cr.BottomLeft.ToString(cultureInfo));
            return(stringBuilder.ToString());
        }
        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        /// <summary>
        /// Creates a string from a VirtualizationCacheLength given the CultureInfo.
        /// </summary>
        /// <param name="cacheLength">VirtualizationCacheLength.</param>
        /// <param name="cultureInfo">Culture Info.</param>
        /// <returns>Newly created string instance.</returns>
        static internal string ToString(VirtualizationCacheLength cacheLength, CultureInfo cultureInfo)
        {
            char listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [64] is an estimate based on a sum of:
            // 24 = 2x double (twelve digits is generous for the range of values likely)
            //  2 = 2x separator characters
            // Is 26 really a good number???
            StringBuilder sb = new StringBuilder(26);

            sb.Append(cacheLength.CacheBeforeViewport.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(cacheLength.CacheAfterViewport.ToString(cultureInfo));
            return(sb.ToString());
        }
Пример #13
0
        /// <summary>
        /// Creates a string representation of this object based on the format string
        /// and IFormatProvider passed in.
        /// If the provider is null, the CurrentCulture is used.
        /// See the documentation for IFormattable for more information.
        /// </summary>
        /// <returns>
        /// A string representation of this object.
        /// </returns>
        internal string ConvertToString(IFormatProvider provider)
        {
            if (IsEmpty)
            {
                return("Empty");
            }

            // Helper to get the numeric list separator for a given culture.
            char separator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider,
                                 "{1}{0}{2}",
                                 separator,
                                 _width,
                                 _height));
        }
Пример #14
0
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            if (IsEmpty)
            {
                return(SR.DirectUI_Empty);
            }

            // Helper to get the numeric list separator for a given culture.
            char separator = TokenizerHelper.GetNumericListSeparator(provider);

            return(String.Format(provider,
                                 "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}",
                                 separator,
                                 _x,
                                 _y,
                                 _width,
                                 _height));
        }
Пример #15
0
        internal string ToString(global::System.Globalization.CultureInfo cultureInfo)
        {
            char listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [64] is an estimate based on a sum of:
            // 48 = 4x double (twelve digits is generous for the range of values likely)
            //  8 = 4x Unit Type string (approx two characters)
            //  4 = 4x separator characters
            global::System.Text.StringBuilder sb = new global::System.Text.StringBuilder(64);

            sb.Append(InternalToString(_TopLeft, cultureInfo));
            sb.Append(listSeparator);
            sb.Append(InternalToString(_TopRight, cultureInfo));
            sb.Append(listSeparator);
            sb.Append(InternalToString(_BottomRight, cultureInfo));
            sb.Append(listSeparator);
            sb.Append(InternalToString(_BottomLeft, cultureInfo));
            return(sb.ToString());
        }
Пример #16
0
//Workaround for PreSharp bug - it complains about value being possibly null even though there is a check above
#pragma warning restore 56506

        #endregion Public Methods

        //-------------------------------------------------------------------
        //
        //  Internal Methods
        //
        //-------------------------------------------------------------------

        #region Internal Methods

        static internal string ToString(CornerRadius cr, CultureInfo cultureInfo)
        {
            char listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [64] is an estimate based on a sum of:
            // 48 = 4x double (twelve digits is generous for the range of values likely)
            //  8 = 4x UnitType string (approx two characters)
            //  4 = 4x separator characters
            StringBuilder sb = new StringBuilder(64);

            sb.Append(cr.TopLeft.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(cr.TopRight.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(cr.BottomRight.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(cr.BottomLeft.ToString(cultureInfo));
            return(sb.ToString());
        }
Пример #17
0
        /// <summary>
        /// Parse - returns an instance converted from the provided string using
        /// the culture "en-US"
        /// </summary>
        /// <param name="source"> string with Point data </param>
        public static Point Parse(string source)
        {
            if (source != null)
            {
                IFormatProvider formatProvider = CultureInfo.InvariantCulture;
                char[] separator = new char[2] { TokenizerHelper.GetNumericListSeparator(formatProvider), ' ' };
                string[] split = source.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                if (split.Length == 2)
                {
                    return new Point(
                        Convert.ToDouble(split[0], formatProvider),
                        Convert.ToDouble(split[1], formatProvider)
                    );
                }
            }

            throw new FormatException($"'{source}' is not an eligible value for a '{typeof(Point)}'.");
        }
Пример #18
0
        internal static Thickness FromString(string s, CultureInfo cultureInfo)
        {
            if (s != null)
            {
                char[] separator = new char[2] {
                    TokenizerHelper.GetNumericListSeparator(cultureInfo), ' '
                };

                string[] split   = s.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                double[] lengths = new double[4];
                int      i       = 0;

                for (; i < split.Length; i++)
                {
                    if (i >= 4)
                    {
                        i = 5;    // Set i to a bad value.
                        break;
                    }

                    lengths[i] = Convert.ToDouble(split[i], cultureInfo);
                }

                // We have a reasonable interpreation for one value (all four edges)
                // and four values (left, top, right, bottom).
                switch (i)
                {
                case 1:
                    return(new Thickness(lengths[0]));

                case 2:
                    return(new Thickness(lengths[0], lengths[1], lengths[0], lengths[1]));

                case 4:
                    return(new Thickness(lengths[0], lengths[1], lengths[2], lengths[3]));
                }
            }

            throw new FormatException(
                      string.Format("'{0}' value is not valid. It must contain one, two, or four delimited Lengths.", s)
                      );
        }
Пример #19
0
        private string ConvertToString(string format, IFormatProvider provider)
        {
            if (IsIdentity)
            {
                return("Identity");
            }

            // Helper to get the numeric list separator for a given culture.
            char separator = TokenizerHelper.GetNumericListSeparator(provider);

            return(String.Format(provider,
                                 "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}{0}{5:" + format + "}{0}{6:" + format + "}",
                                 separator,
                                 _m11,
                                 _m12,
                                 _m21,
                                 _m22,
                                 _offsetX,
                                 _offsetY));
        }
Пример #20
0
        private string ConvertToString(string?format, IFormatProvider?provider)
        {
            if (IsIdentity)
            {
                return("Identity");
            }

            // Helper to get the numeric list separator for a given culture.
            char separator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider,
                                 "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}{0}{4:" + format + "}{0}{5:" + format +
                                 "}{0}{6:" + format + "}{0}{7:" + format + "}{0}{8:" + format + "}{0}{9:" + format + "}{0}{10:" + format +
                                 "}{0}{11:" + format + "}{0}{12:" + format + "}{0}{13:" + format + "}{0}{14:" + format + "}{0}{15:" + format + "}{0}{16:" + format + "}",
                                 separator,
                                 _m11, _m12, _m13, _m14,
                                 _m21, _m22, _m23, _m24,
                                 _m31, _m32, _m33, _m34,
                                 _offsetX, _offsetY, _offsetZ, _m44));
        }
Пример #21
0
        public static DoubleCollection Parse(string source)
        {
            var db = new DoubleCollection();

            if (source != null)
            {
                IFormatProvider formatProvider = CultureInfo.InvariantCulture;
                char[]          separator      = new char[2] {
                    TokenizerHelper.GetNumericListSeparator(formatProvider), ' '
                };
                string[] split = source.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < split.Length; i++)
                {
                    db.Add(Convert.ToDouble(split[i], formatProvider));
                }
            }

            return(db);
        }
Пример #22
0
        internal string ToString(global::System.Globalization.CultureInfo cultureInfo)
        {
            char listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [64] is an estimate based on a sum of:
            // 12 = 1x double (twelve digits is generous for the range of values likely)
            //  8 = 4x Unit Type string (approx two characters)
            //  2 = 2x separator characters

            if (_unitType == GridUnitType.Auto)
            {
                return("Auto");
            }
            else if (_unitType == GridUnitType.Pixel)
            {
                return(Convert.ToString(_unitValue, cultureInfo));
            }
            else
            {
                return(Convert.ToString(_unitValue, cultureInfo) + "*");
            }
        }
Пример #23
0
        private static string ToString(ColLayout th, CultureInfo cultureInfo)
        {
            var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

            // Initial capacity [128] is an estimate based on a sum of:
            // 72 = 6x double (twelve digits is generous for the range of values likely)
            //  4 = 4x separator characters
            var sb = new StringBuilder(128);

            sb.Append(th.Xs.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(th.Sm.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(th.Md.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(th.Lg.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(th.Xl.ToString(cultureInfo));
            sb.Append(listSeparator);
            sb.Append(th.Xxl.ToString(cultureInfo));
            return(th.ToString());
        }
Пример #24
0
        internal string ConvertToString(string?format, IFormatProvider?provider)
        {
            StringBuilder sb = new StringBuilder();

            if (format == null)
            {
                sb.AppendFormat(provider, "#{0:X2}", _A);
                sb.AppendFormat(provider, "{0:X2}", _R);
                sb.AppendFormat(provider, "{0:X2}", _G);
                sb.AppendFormat(provider, "{0:X2}", _B);
            }
            else
            {
                // Helper to get the numeric list separator for a given culture.
                char separator = TokenizerHelper.GetNumericListSeparator(provider);

                sb.AppendFormat(provider,
                                "sc#{1:" + format + "}{0} {2:" + format + "}{0} {3:" + format + "}{0} {4:" + format + "}",
                                separator, _A, _R, _G, _B);
            }

            return(sb.ToString());
        }
Пример #25
0
    public override string ToString()
    {
        var cultureInfo   = CultureInfo.CurrentCulture;
        var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);

        // Initial capacity [128] is an estimate based on a sum of:
        // 72 = 6x double (twelve digits is generous for the range of values likely)
        //  4 = 4x separator characters
        var sb = new StringBuilder(128);

        sb.Append(Xs.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Sm.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Md.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Lg.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Xl.ToString(cultureInfo));
        sb.Append(listSeparator);
        sb.Append(Xxl.ToString(cultureInfo));
        return(sb.ToString());
    }
Пример #26
0
        internal string ConvertToString(string format, IFormatProvider provider)
        {
            char numericListSeparator = TokenizerHelper.GetNumericListSeparator(provider);

            return(string.Format(provider, "{1:" + format + "}{0}{2:" + format + "}{0}{3:" + format + "}", new object[] { numericListSeparator, this.X, this.Y, this.Z }));
        }