public void AddExample(Unistroke p) { var success = true; try { // first, ensure that p's name is right var name = ParseName(p.Name); if (name != _name) { throw new ArgumentException("Prototype name does not equal the name of the category to which it was added."); } // second, ensure that it doesn't already exist if (_prototypes.Any(p0 => p0.Name == p.Name)) { throw new ArgumentException("Prototype name was added more than once to its category."); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); success = false; } if (success) { _prototypes.Add(p); } }
public Category(string name, Unistroke firstExample) { _name = name; //_prototypes = new ArrayList(); _prototypes = new List <Unistroke>(); AddExample(firstExample); }