Beispiel #1
0
        // 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);
        }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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);
            }
        }