using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Svg
{
///
/// Represents a list of .
///
[TypeConverter(typeof(SvgUnitCollectionConverter))]
public class SvgUnitCollection : List
{
}
///
/// A class to convert string into instances.
///
internal class SvgUnitCollectionConverter : TypeConverter
{
private static readonly SvgUnitConverter _unitConverter = new SvgUnitConverter();
///
/// Converts the given object to the type of this converter, using the specified context and culture information.
///
/// An that provides a format context.
/// The to use as the current culture.
/// The to convert.
///
/// An that represents the converted value.
///
/// The conversion cannot be performed.
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
string[] points = ((string)value).Trim().Split(new char[] { ',', ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
SvgUnitCollection units = new SvgUnitCollection();
foreach (string point in points)
{
units.Add((SvgUnit)_unitConverter.ConvertFrom(point.Trim()));
}
return units;
}
return base.ConvertFrom(context, culture, value);
}
}
}