コード例 #1
0
        public void ObjectChanged(INakedObjectAdapter nakedObjectAdapter, ILifecycleManager lifecycleManager, IMetamodelManager metamodel)
        {
            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(Log.LogAndReturn("cannot change immutable object"));
                    }
                    nakedObjectAdapter.Updating();

                    if (!spec.IsNeverPersisted())
                    {
                        objectStore.ExecuteSaveObjectCommand(nakedObjectAdapter);
                    }
                    nakedObjectAdapter.Updated();
                }
            }

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