コード例 #1
0
        public void ObjectChanged(INakedObjectAdapter nakedObjectAdapter, ILifecycleManager lifecycleManager, IMetamodelManager metamodel)
        {
            Log.DebugFormat("ObjectChanged nakedObjectAdapter: {0}", nakedObjectAdapter);
            if (nakedObjectAdapter.ResolveState.RespondToChangesInPersistentObjects())
            {
                if (nakedObjectAdapter.Spec.ContainsFacet(typeof(IComplexTypeFacet)))
                {
                    nakedObjectAdapter.Updating();
                    nakedObjectAdapter.Updated();
                }
                else
                {
                    ITypeSpec spec = nakedObjectAdapter.Spec;
                    if (spec.IsAlwaysImmutable() || (spec.IsImmutableOncePersisted() && nakedObjectAdapter.ResolveState.IsPersistent()))
                    {
                        throw new NotPersistableException("cannot change immutable object");
                    }
                    nakedObjectAdapter.Updating();
                    objectStore.ExecuteSaveObjectCommand(nakedObjectAdapter);
                    nakedObjectAdapter.Updated();
                }
            }

            if (nakedObjectAdapter.ResolveState.RespondToChangesInPersistentObjects() ||
                nakedObjectAdapter.ResolveState.IsTransient())
            {
            }
        }