private IEnumerable <string> GetColumnNamesForTile(CaseInsensitivePropertyEqualityComparer comparer) { List <string> toReturn = new List <string>(); // Name is required and always available toReturn.Add("Name (string, required)"); // And animation is required too toReturn.Add(animationColumnName); toReturn.AddRange(this.Tilesets.SelectMany(t => t.Tiles) .SelectMany(tile => tile.PropertyDictionary) .Select(d => d.Key) //.Distinct(comparer) .ToList()); foreach (var group in this.objectgroup) { bool addedGroup = false; foreach (var @object in group.@object) { if (!String.IsNullOrEmpty(@object.gid)) { addedGroup = true; toReturn.AddRange(@object.PropertyDictionary.Keys); } } if (addedGroup) { toReturn.AddRange(group.PropertyDictionary.Keys); } } return(toReturn.Distinct(comparer)); }
private IEnumerable <string> GetColumnNames(CSVPropertyType type, string layerName) { var comparer = new CaseInsensitivePropertyEqualityComparer(); var columnNames = new HashSet <string>(); switch (type) { case CSVPropertyType.Tile: return(GetColumnNamesForTile(comparer)); case CSVPropertyType.Layer: return (this.Layers.Where( l => layerName == null || (l.Name != null && l.Name.Equals(layerName, StringComparison.OrdinalIgnoreCase))) .SelectMany(l => l.PropertyDictionary) .Select(d => d.Key) .Distinct(comparer)); case CSVPropertyType.Map: return(this.PropertyDictionary.Select(d => d.Key).Distinct(comparer)); case CSVPropertyType.Object: List <string> toReturn = new List <string>(); toReturn.Add("X (int)"); toReturn.Add("Y (int)"); if (objectgroup != null) { var query1 = objectgroup.Where(l => layerName == null || (l.name != null && l.name.Equals(layerName, StringComparison.OrdinalIgnoreCase))); var query2 = objectgroup.Where(l => layerName == null || (l.name != null && l.name.Equals(layerName, StringComparison.OrdinalIgnoreCase))); return(toReturn .Union(query1 .SelectMany(o => o.@object) .Where(o => String.IsNullOrEmpty(o.gid)) //November 2015 by Jesse Crafts-Finch: will ignore objects which are to be treated as sprites (they have a gid). .SelectMany(o => o.PropertyDictionary) .Select(d => d.Key), comparer) .Union(query2 .SelectMany(o => o.PropertyDictionary) .Select(d => d.Key), comparer)); } else { return(toReturn); } } return(columnNames); }