Ejemplo n.º 1
0
        public static IEnumerable <Modifiable> IdentifiableExplore(Modifiable obj)
        {
            if (obj == null)//|| obj is Lite)
            {
                yield break;
            }

            if (Reflector.IsMList(obj.GetType()))
            {
                Type t = obj.GetType().ElementType();

                if (t.IsModifiable() && !t.IsEntity())
                {
                    IEnumerable col = obj as IEnumerable;
                    foreach (Modifiable item in col)
                    {
                        if (item != null)
                        {
                            yield return(item);
                        }
                    }
                }
            }
            else
            {
                foreach (Func <object, object> getter in ModifiableFieldGetters(obj.GetType()))
                {
                    object field = getter(obj);

                    if (field == null || field is Entity)
                    {
                        continue;
                    }

                    yield return((Modifiable)field);
                }

                Entity ident = obj as Entity;
                if (ident != null)
                {
                    foreach (var mixin in ident.Mixins)
                    {
                        yield return(mixin);
                    }
                }
            }
        }
        public static IEnumerable <Modifiable> FullExploreVirtual(Modifiable obj)
        {
            if (obj == null)
            {
                yield break;
            }

            if (Reflector.IsMList(obj.GetType()))
            {
                Type t = obj.GetType().ElementType();
                if (Reflector.IsModifiableIdentifiableOrLite(t))
                {
                    IEnumerable col = obj as IEnumerable;
                    foreach (Modifiable item in col)
                    {
                        if (item != null)
                        {
                            yield return(item);
                        }
                    }
                }
            }
            else
            {
                foreach (Func <object, object> getter in ModifiableFieldGettersVirtual(obj.GetType()))
                {
                    object field = getter(obj);

                    if (field == null)
                    {
                        continue;
                    }

                    yield return((Modifiable)field);
                }

                if (obj is Entity ident)
                {
                    foreach (var mixin in ident.Mixins)
                    {
                        yield return(mixin);
                    }
                }
            }
        }