Exemple #1
0
 /// <summary>Recurses the objects within a persistence boundary, excluding objects
 ///     decorated with NotPersisted and the persistence boundary object's parent
 ///     object.</summary>
 /// 
 /// <param name="obj"></param>
 /// 
 /// <returns></returns>
 public ICollection RecursePersistenceBoundaryGraph(IPersistenceBoundary obj)
 {
     return RecurseObjectGraph(obj,
                               obj,
                               null,
                               new ProcessObjectFilterDelegate(PersistenceBoundaryObjectFilter));
 }
Exemple #2
0
        public void Update(IPersistenceBoundary obj)
        {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            //If this object's type hasn't been processed already, process it now
            if (!_typeProcessor.IsAssemblyProcessed(obj.GetType().Assembly)) {
                _typeProcessor.ProcessAssembly(obj.GetType().Assembly);
            }

            //If this object is active, update it in the store, calling
            //its callback methods if present.  If it's not active, calling
            //Update is bogus
            if (!IsActivated(obj)) {
                throw new InvalidOperationException();
            }

            _recursor.RecursivelyDo(_recursor.RecursePersistenceBoundaryGraph(obj),
                                    null,
                                    new RecursiveOperationDelegate(DoUpdateObject));
        }
Exemple #3
0
        public bool IsActivated(IPersistenceBoundary obj)
        {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            //If this object's type hasn't been processed already, process it now
            if (!_typeProcessor.IsAssemblyProcessed(obj.GetType().Assembly)) {
                _typeProcessor.ProcessAssembly(obj.GetType().Assembly);
            }

            return _container.isActive(obj);
        }
Exemple #4
0
        public void Delete(IPersistenceBoundary obj)
        {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            //If this object's type hasn't been processed already, process it now
            if (!_typeProcessor.IsAssemblyProcessed(obj.GetType().Assembly)) {
                _typeProcessor.ProcessAssembly(obj.GetType().Assembly);
            }

            //If this object is stored, delete it from the store, calling
            //its callback methods if present
            if (_container.isStored(obj)) {
                _recursor.RecursivelyDo(_recursor.RecursePersistenceBoundaryGraph(obj),
                                        null,
                                        new RecursiveOperationDelegate(DoDeleteObject));
            }
        }
Exemple #5
0
        public void Add(IPersistenceBoundary obj)
        {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            //If this object's type hasn't been processed already, process it now
            if (!_typeProcessor.IsAssemblyProcessed(obj.GetType().Assembly)) {
                _typeProcessor.ProcessAssembly(obj.GetType().Assembly);
            }

            //Add the object without regard for whether it's currently in the store/
            //in db4o, an add and an update are the same operation (set()), therefore
            //it is not important to strictly distinguish adds from updates, and
            //its possible that some Content Model slieght-of-hand caused the persistence boundary
            //to be added, without the recursive add of referenced objects that this method
            //does
            _recursor.RecursivelyDo(_recursor.RecursePersistenceBoundaryGraph(obj),
                                    null,
                                    new RecursiveOperationDelegate(DoAddObject));
        }
Exemple #6
0
        public void Activate(IPersistenceBoundary obj)
        {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }

            //If this object's type hasn't been processed already, process it now
            if (!_typeProcessor.IsAssemblyProcessed(obj.GetType().Assembly)) {
                _typeProcessor.ProcessAssembly(obj.GetType().Assembly);
            }

            //If this type is stored and not activated, activate it
            //If it is activated, you can't double-activate
            if (IsActivated(obj)) {
                throw new InvalidOperationException();
            }

            _recursor.RecursivelyDo(_recursor.RecursePersistenceBoundaryGraph(obj),
                                    null,
                                    new RecursiveOperationDelegate(DoActivateObject));
        }