private string EnsureUniqueName(string name) { if (Layers.Any(x => x.LayerName == name)) { string originalName = name; bool unique; int counter = 2; do { name = string.Format("{0} - {1}", originalName, counter++); unique = Layers.All(x => x.LayerName != name); } while (!unique); } return(name); }