public static string GetPositionedObjectBreakdown() { Dictionary <string, CountedCategory> typeDictionary = new Dictionary <string, CountedCategory>(); int count = SpriteManager.ManagedPositionedObjects.Count; for (int i = 0; i < count; i++) { var atI = SpriteManager.ManagedPositionedObjects[i]; Type type = atI.GetType(); if (typeDictionary.ContainsKey(type.Name) == false) { var countedCategory = new CountedCategory(); countedCategory.String = type.Name; typeDictionary.Add(type.Name, countedCategory); } typeDictionary[type.Name].Count++; } StringBuilder stringBuilder = GetFilledStringBuilderWithNumberedTypes(typeDictionary); string toReturn = "Total: " + count + "\n" + stringBuilder.ToString(); if (count == 0) { toReturn = "No automatically updated PositionedObjects"; } return(toReturn); }
public static string GetAutomaticallyUpdatedBreakdownFromList <T>(IEnumerable <T> list) where T : PositionedObject { Dictionary <string, CountedCategory> typeDictionary = new Dictionary <string, CountedCategory>(); bool isIVisible = false; if (list.Count() != 0) { isIVisible = list.First() is IVisible; } foreach (var atI in list) { string typeName = "Unparented"; if (typeof(T) != atI.GetType()) { typeName = atI.GetType().Name; } else if (atI.Parent != null) { typeName = atI.Parent.GetType().Name; } if (typeDictionary.ContainsKey(typeName) == false) { var toAdd = new CountedCategory(); toAdd.String = typeName; typeDictionary.Add(typeName, toAdd); } typeDictionary[typeName].Count++; if (isIVisible && !((IVisible)atI).AbsoluteVisible) { typeDictionary[typeName].Invisible++; } } string toReturn = "Total: " + list.Count() + " " + typeof(T).Name + "s\n" + GetFilledStringBuilderWithNumberedTypes(typeDictionary).ToString(); if (list.Count() == 0) { toReturn = "No automatically updated " + typeof(T).Name + "s"; } return(toReturn); }
public static string GetShapeBreakdown() { Dictionary <string, CountedCategory> typeDictionary = new Dictionary <string, CountedCategory>(); foreach (PositionedObject shape in ShapeManager.AutomaticallyUpdatedShapes) { var parent = shape.Parent; string parentType = "<null>"; if (parent != null) { parentType = parent.GetType().Name; } if (typeDictionary.ContainsKey(parentType) == false) { var countedCategory = new CountedCategory(); countedCategory.String = parentType; typeDictionary.Add(parentType, countedCategory); } typeDictionary[parentType].Count++; } StringBuilder stringBuilder = GetFilledStringBuilderWithNumberedTypes(typeDictionary); var count = ShapeManager.AutomaticallyUpdatedShapes.Count; string toReturn = "Total: " + count + "\n" + stringBuilder.ToString(); if (count == 0) { toReturn = "No automatically updated Shapes"; } return(toReturn); }