// DFS without indent public static void TraversalDFS( ISIS.GME.Common.Classes.Base subject, Action <ISIS.GME.Common.Classes.Base> action) { Contract.Requires(subject != null); action(subject); ChildTraversalDFS(subject, action); }
private static void ChildTraversalDFS( ISIS.GME.Common.Classes.Base subject, Action <ISIS.GME.Common.Classes.Base> action) { Contract.Requires(subject != null); if (subject is ISIS.GME.Common.Interfaces.Container) { foreach (ISIS.GME.Common.Classes.Base o in (subject as ISIS.GME.Common.Interfaces.Container).AllChildren.Distinct()) { action(o); ChildTraversalDFS(o, action); } } }
public static IEnumerable <ISIS.GME.Common.Interfaces.Base> CastMgaChildren <TSource>( this TSource source, Dictionary <int, Type> metaRefTypes) where TSource : MgaObjects { Contract.Requires(source != null); IEnumerable <IMgaObject> children = source.Cast <IMgaObject>(); // return with the specifed kinds only foreach (IMgaObject v in children) { ISIS.GME.Common.Classes.Base newObject = null; newObject = Activator.CreateInstance(metaRefTypes[v.MetaBase.MetaRef]) as ISIS.GME.Common.Classes.Base; newObject.Impl = v as IMgaObject; yield return(newObject); } }