Cascading MarkOld when using ObjectFactory

Cascading MarkOld when using ObjectFactory

Old forum URL: forums.lhotka.net/forums/t/8031.aspx


Kevin Fairclough posted on Monday, November 23, 2009

Hi

I have a method which is meant to cascade a MarkOld call to an object graph using an exposed FieldManager,  I would appreciate feedback to see if the method looks ok.  I am assuming that FieldManager deals with any inherited objects.  I intend in the future to use similar method to cascade all DAL operations, creating a fine-grained DAL.

private void CascadeMarkOld(object obj)
        {
            //FieldManager consolidates all inherited objects           
            MethodCaller.CallMethod(obj, "MarkOld", null);

            IList childObjects = null;
            if (obj is IFieldManager)
                childObjects = ((IFieldManager)obj).CslaFieldManager.GetChildren();

            if (childObjects != null)
                foreach (var child in childObjects)
                    if (child is Csla.Core.IEditableCollection)                   
                        if (((Csla.Core.IEditableCollection)child).IsSelfDirty)
                        {
                            MethodCaller.CallMethod(child, "ClearDeletedList", null);
                            foreach (var item in (IEnumerable) child)
                                CascadeMarkOld(item);
                        }
                   
                    else
                        CascadeMarkOld(child);
        }


Is there a better way to do this, does it look correct?

TIA
Kevin

Copyright (c) Marimer LLC