コード例 #1
0
        /// <summary>
        /// Check if the property is initialized. If the named property does not exist
        /// or is not persistent, this method always returns <tt>true</tt>.
        /// </summary>
        /// <param name="proxy">The potential proxy </param>
        /// <param name="propertyName">the name of a persistent attribute of the object </param>
        /// <returns>
        /// true if the named property of the object is not listed as uninitialized;
        /// false if the object is an uninitialized proxy, or the named property is uninitialized
        /// </returns>
        public static bool IsPropertyInitialized(object proxy, string propertyName)
        {
            object entity;

            if (proxy is INHibernateProxy)
            {
                ILazyInitializer li = ((INHibernateProxy)proxy).HibernateLazyInitializer;
                if (li.IsUninitialized)
                {
                    return(false);
                }
                else
                {
                    entity = li.GetImplementation();
                }
            }
            else
            {
                entity = proxy;
            }

            if (FieldInterceptionHelper.IsInstrumented(entity))
            {
                IFieldInterceptor interceptor = FieldInterceptionHelper.ExtractFieldInterceptor(entity);
                return(interceptor == null || interceptor.IsInitializedField(propertyName));
            }
            else
            {
                return(true);
            }
        }
コード例 #2
0
 public bool RequiresDirtyCheck(object entity)
 {
     return
         (IsModifiableEntity() &&
          (Persister.HasMutableProperties || !FieldInterceptionHelper.IsInstrumented(entity) ||
           FieldInterceptionHelper.ExtractFieldInterceptor(entity).IsDirty));
 }
コード例 #3
0
        public bool RequiresDirtyCheck(object entity)
        {
            bool isMutableInstance = status != Status.ReadOnly && persister.IsMutable;

            return
                (isMutableInstance
                 &&
                 (Persister.HasMutableProperties || !FieldInterceptionHelper.IsInstrumented(entity) ||
                  FieldInterceptionHelper.ExtractFieldInterceptor(entity).IsDirty));
        }
コード例 #4
0
 private void MarkInterceptorDirty(object entity, object target)
 {
     if (FieldInterceptionHelper.IsInstrumented(entity))
     {
         IFieldInterceptor interceptor = FieldInterceptionHelper.ExtractFieldInterceptor(target);
         if (interceptor != null)
         {
             interceptor.MarkDirty();
         }
     }
 }
コード例 #5
0
 public override bool HasUninitializedLazyProperties(object entity)
 {
     if (EntityMetamodel.HasLazyProperties)
     {
         IFieldInterceptor callback = FieldInterceptionHelper.ExtractFieldInterceptor(entity);
         return(callback != null && !callback.IsInitialized);
     }
     else
     {
         return(false);
     }
 }
コード例 #6
0
        internal override ISet <string> GetUninitializedLazyProperties(object entity)
        {
            if (!EntityMetamodel.HasLazyProperties)
            {
                return(CollectionHelper.EmptySet <string>());
            }

            var interceptor = FieldInterceptionHelper.ExtractFieldInterceptor(entity);

            if (interceptor == null)
            {
                return(CollectionHelper.EmptySet <string>());
            }

            return(interceptor.GetUninitializedFields() ?? lazyPropertyNames);
        }
コード例 #7
0
        public static System.Type GetProxyRealType(this ISession session, object proxy)
        {
            var obj = proxy;

            if (proxy.IsProxy())
            {
                obj = ((INHibernateProxy)proxy).HibernateLazyInitializer.GetImplementation();
            }

            var fieldAccessor = FieldInterceptionHelper.ExtractFieldInterceptor(obj);

            if (fieldAccessor != null)
            {
                return(fieldAccessor.MappedClass);
            }

            return(obj.GetType());
        }
コード例 #8
0
        public static bool IsPropertyInitialized(object proxy, string propertyName)
        {
            object entity;

            if (!IsProxyFactoryConfigurated())
            {
                //if the proxy provider it's not configurated, can't be a proxy neither an instrumented field.
                return(true);
            }

            if (proxy.IsProxy())
            {
                ILazyInitializer li = ((INHibernateProxy)proxy).HibernateLazyInitializer;
                if (li.IsUninitialized)
                {
                    return(false);
                }
                else
                {
                    entity = li.GetImplementation();
                }
            }
            else
            {
                entity = proxy;
            }

            if (FieldInterceptionHelper.IsInstrumented(entity))
            {
                IFieldInterceptor interceptor = FieldInterceptionHelper.ExtractFieldInterceptor(entity);
                return(interceptor == null || interceptor.IsInitializedField(propertyName));
            }
            else
            {
                return(true);
            }
        }