public static List<IGraphicItem> GetGraphicItemsFromObject(object obj) { if(null == obj) return null; List<IGraphicItem> items = new List<IGraphicItem>(); System.Type objType = obj.GetType(); IEnumerable collection = obj as IEnumerable; if (null != collection) { foreach (var item in collection) { List<IGraphicItem> graphics = GetGraphicItemsFromObject(item); if (null != graphics) items.AddRange(graphics); } return items; } IGraphicItem graphicItem = obj as IGraphicItem; if (graphicItem != null) { items.Add(graphicItem); return items; } IGraphicDataProvider dataProvider = GetGraphicDataProviderForType(objType); if (null == dataProvider) { dataProvider = new GraphicObjectType(objType); mGraphicTypes.Add(objType, dataProvider); } return dataProvider.GetGraphicItems(obj); }
public static List <IGraphicItem> GetGraphicItemsFromObject(object obj) { if (null == obj) { return(null); } List <IGraphicItem> items = new List <IGraphicItem>(); System.Type objType = obj.GetType(); IEnumerable collection = obj as IEnumerable; if (null != collection) { foreach (var item in collection) { try { List <IGraphicItem> graphics = GetGraphicItemsFromObject(item); if (null != graphics) { items.AddRange(graphics); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("GetGraphicItems: " + e); } } return(items); } IGraphicItem graphicItem = obj as IGraphicItem; if (graphicItem != null) { items.Add(graphicItem); return(items); } IGraphicDataProvider dataProvider = GetGraphicDataProviderForType(objType); if (null == dataProvider) { dataProvider = new GraphicObjectType(objType); mGraphicTypes.Add(objType, dataProvider); } return(dataProvider.GetGraphicItems(obj)); }