/// <summary> /// Clone the collection of organized points. /// </summary> /// <returns>A clone of the organized points.</returns> public OrganizedPointCollection Clone() { OrganizedPointCollection clonedOPC = new OrganizedPointCollection(); foreach (KeyValuePair <int, Dictionary <int, List <OrganizedPoint> > > xSection in collection) { //This must be created each time to ensure that it is fresh for each loop iteration. Dictionary <int, List <OrganizedPoint> > tempSection = new Dictionary <int, List <OrganizedPoint> >(); foreach (KeyValuePair <int, List <OrganizedPoint> > section in xSection.Value) { tempSection.Add(section.Key, section.Value.Select(i => new OrganizedPoint(new PointD(i.Position.X, i.Position.Y), i.Index)).ToList()); } clonedOPC.collection.Add(xSection.Key, tempSection); } return(clonedOPC); }
/// <summary> /// Clone the collection of organized points. /// </summary> /// <returns>A clone of the organized points.</returns> public OrganizedPointCollection Clone() { OrganizedPointCollection clonedOPC = new OrganizedPointCollection(); foreach (KeyValuePair<int, Dictionary<int, List<OrganizedPoint>>> xSection in collection) { //This must be created each time to ensure that it is fresh for each loop iteration. Dictionary<int, List<OrganizedPoint>> tempSection = new Dictionary<int, List<OrganizedPoint>>(); foreach (KeyValuePair<int, List<OrganizedPoint>> section in xSection.Value) { tempSection.Add(section.Key, section.Value.Select(i => new OrganizedPoint(new PointD(i.Position.X, i.Position.Y), i.Index)).ToList()); } clonedOPC.collection.Add(xSection.Key, tempSection); } return clonedOPC; }