public static object LastObject(this HttpSessionStateBase session, IFrameworkFacade facade, ObjectFlag flag = ObjectFlag.None) { KeyValuePair <string, CacheMemento> lastEntry = session.GetCache(flag).OrderBy(kvp => kvp.Value.Added).LastOrDefault(); if (lastEntry.Equals(default(KeyValuePair <string, CacheMemento>))) { return(null); } var lastObject = SafeGetNakedObjectFromId(lastEntry.Key, facade); if (lastObject == null) { session.GetCache(flag).Remove(lastEntry.Key); return(session.LastObject(facade, flag)); } return(lastObject.GetDomainObject()); }
public static object LastObject(this HttpSessionStateBase session, INakedObjectsFramework framework, ObjectFlag flag = ObjectFlag.None) { KeyValuePair <string, CacheMemento> lastEntry = session.GetCache(flag).OrderBy(kvp => kvp.Value.Added).LastOrDefault(); if (lastEntry.Equals(default(KeyValuePair <string, CacheMemento>))) { return(null); } INakedObject lastObject = SafeGetNakedObjectFromId(lastEntry.Key, framework); if (lastObject.ResolveState.IsDestroyed()) { session.GetCache(flag).Remove(lastEntry.Key); return(session.LastObject(framework, flag)); } return(lastObject.Object); }