Esempio n. 1
0
        /// <summary>
        /// Converts the given object to the type of this converter, using the specified context and culture information.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param>
        /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo"/> to use as the current culture.</param>
        /// <param name="value">The <see cref="T:System.Object"/> to convert.</param>
        /// <returns>
        /// An <see cref="T:System.Object"/> that represents the converted value.
        /// </returns>
        /// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
        public override SvgUnitCollection Convert(string value)
        {
            if (string.Compare(((string)value).Trim(), "none", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return(null);
            }
            string[]          points = ((string)value).Trim().Split(new char[] { ',', ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            SvgUnitCollection units  = new SvgUnitCollection();

            foreach (string point in points)
            {
                SvgUnit newUnit = _unitConverter.Convert(point.Trim());
                if (!newUnit.IsNone)
                {
                    units.Add(newUnit);
                }
            }

            return(units);
        }