public void OnLoad(NHibernate.Event.LoadEvent @event, LoadType loadType) { if (null == @event.Result) return; // Short circuit if (!ShouldContinue(@event.Session, @event.Result.GetType())) return; ISecurable securable = @event.Result as ISecurable; if (null == securable) { // TODO: Consider making this an Exception... System.Console.WriteLine("Implements ISecurable but can't be cast as ISecurable..."); return; } // Attempt at fixing the Day->Trip problem... if ("InternalLoadLazy".Equals(loadType.ToString())) return; var entityName = @event.Session.GetFilterParameterValue("EntityNameFilter.EntityName") as string; //bool canLoad = securable.GetAccessList().Where(ace => ace.EntityName == entityName).Any(); System.Console.WriteLine("ACL size: {0}", securable.AccessControlList.Count()); bool canLoad = securable.IsLoadableFor(entityName); System.Console.WriteLine("loadType {0}\tLockMode: {1}", loadType, @event.LockMode); System.Console.WriteLine("CanLoad entity {2} for organization [{0}]? {1}", entityName, canLoad, @event.Result.GetType().FullName); if (!canLoad) { @event.Result = null; } }
public new void OnLoad(LoadEvent @event, LoadType loadType) { var source = (ISessionImplementor)@event.Session; IEntityPersister entityPersister; if (@event.InstanceToLoad != null) { entityPersister = source.GetEntityPersister(null, @event.InstanceToLoad); @event.EntityClassName = @event.InstanceToLoad.GetType().FullName; } else entityPersister = source.Factory.GetEntityPersister(@event.EntityClassName); if (entityPersister == null) throw new HibernateException("Unable to locate persister: " + @event.EntityClassName); //a hack to handle unused ContentPartRecord proxies on ContentItemRecord or ContentItemVersionRecord. //I don't know why it actually works, or how to do it right //if (!entityPersister.IdentifierType.IsComponentType) //{ // Type returnedClass = entityPersister.IdentifierType.ReturnedClass; // if (returnedClass != null && !returnedClass.IsInstanceOfType(@event.EntityId)) // throw new TypeMismatchException(string.Concat(new object[4] // { // (object) "Provided id of the wrong type. Expected: ", // (object) returnedClass, // (object) ", got ", // (object) @event.EntityId.GetType() // })); //} var keyToLoad = new EntityKey(@event.EntityId, entityPersister, source.EntityMode); if (loadType.IsNakedEntityReturned) { @event.Result = Load(@event, entityPersister, keyToLoad, loadType); } else if (@event.LockMode == LockMode.None) { @event.Result = ProxyOrLoad(@event, entityPersister, keyToLoad, loadType); } else { @event.Result = LockAndLoad(@event, entityPersister, keyToLoad, loadType, source); } }
public void OnLoad(LoadEvent @event, LoadType loadType){}
public void OnLoad(LoadEvent @event, LoadType loadType) { Debug.WriteLine("EventListener.OnLoad: {0}", @event.EntityId); }
protected override object DoLoad(LoadEvent @event, IEntityPersister persister, EntityKey keyToLoad, LoadType options) { return base.DoLoad(@event, persister, keyToLoad, options); }
public void OnLoad(LoadEvent @event, LoadType loadType) { log.Debug("OnLoad :" + @event); }