private void OnInitialLoad(object key, object value) { _idMap.Add(key, value); GetDocumentItem(key, value.GetType()).DocumentLoadedFromBackingStore(value); if (Interceptor != null) { Interceptor.AfterLoad(value); } }
public virtual bool TryGetVersion <TDocument>(object key, out TDocument document, int version = -1) { var requiresVersioning = version > 0; _usageGuard.AssertNoContextChangeOccurred(this); if (!HandlesDocumentType <TDocument>(requireVersioningSupport: requiresVersioning)) { document = default(TDocument); return(false); } var documentType = typeof(TDocument); if (documentType.IsInterface) { throw new ArgumentException("You cannot query by id for an interface type. There is no guarantee of uniqueness"); } if (!requiresVersioning && _idMap.TryGet(key, out document) && documentType.IsInstanceOfType(document)) { return(true); } document = TryGenerateModel <TDocument>(key, version); if (!Equals(document, default(TDocument))) { _interceptor.AfterLoad(document); if (!requiresVersioning) { _idMap.Add(key, document); } return(true); } return(false); }