Example #1
0
        public virtual void EnsurePropertyIsLoaded(object obj, IPropertyMap propertyMap)
        {
            IObjectManager     om = this.Context.ObjectManager;
            IPersistenceEngine pe = this.Context.PersistenceEngine;
            ObjectStatus       objStatus;
            PropertyStatus     propStatus;

            objStatus = om.GetObjectStatus(obj);
            if (objStatus != ObjectStatus.Deleted)
            {
                if (objStatus == ObjectStatus.NotLoaded)
                {
                    pe.LoadObject(ref obj);
                    if (pe == null)
                    {
                        throw new ObjectNotFoundException("Object not found!");                         // do not localize
                    }
                }
                propStatus = om.GetPropertyStatus(obj, propertyMap.Name);
                if (propStatus == PropertyStatus.NotLoaded)
                {
                    pe.LoadProperty(obj, propertyMap.Name);
                }
            }
            else
            {
                //We really ought to throw an exception here...
            }
        }