public LuceneSession(IDocumentMapper <T> mapper, IDocumentModificationDetector <T> detector, IIndexWriter writer, Context context, IQueryable <T> queryable) { this.mapper = mapper; this.writer = writer; this.context = context; this.queryable = queryable; documentTracker = new SessionDocumentTracker(detector); }
public void SetUp() { mapper = MockRepository.GenerateStrictMock<IDocumentMapper<Record>>(); detector = MockRepository.GenerateStrictMock<IDocumentModificationDetector<Record>>(); writer = MockRepository.GenerateStrictMock<IIndexWriter>(); context = MockRepository.GenerateStub<Context>(null, new object()); session = new LuceneSession<Record>(mapper, detector, writer, context, null); mapper.Expect(m => m.ToKey(Arg<Record>.Is.NotNull)) .WhenCalled(mi => mi.ReturnValue = new DocumentKey(new Dictionary<IFieldMappingInfo, object> { { new FakeFieldMappingInfo { FieldName = "Id"}, ((Record)mi.Arguments[0]).Id } })) .Repeat.Any(); }
public void SetUp() { mapper = MockRepository.GenerateStrictMock <IDocumentMapper <Record> >(); detector = MockRepository.GenerateStrictMock <IDocumentModificationDetector <Record> >(); writer = MockRepository.GenerateStrictMock <IIndexWriter>(); context = MockRepository.GenerateStub <Context>(null, new object()); session = new LuceneSession <Record>(mapper, detector, writer, context, null); mapper.Expect(m => m.ToKey(Arg <Record> .Is.NotNull)) .WhenCalled(mi => mi.ReturnValue = new DocumentKey(new Dictionary <IFieldMappingInfo, object> { { new FakeFieldMappingInfo { FieldName = "Id" }, ((Record)mi.Arguments[0]).Id } })) .Repeat.Any(); }
/// <summary> /// Opens a session for staging changes and then committing them atomically. /// </summary> /// <param name="lookup">Factory delegate that resolves instances of <typeparamref name="T"/></param> /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param> /// <param name="documentModificationDetector">Helper to determine when instances of <typeparamref name="T"/> are modified /// and need to be updated in the index when the session is committed. /// </param> /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam> public virtual ISession <T> OpenSession <T>(ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector) { perFieldAnalyzer.Merge(documentMapper.Analyzer); return(new LuceneSession <T>( documentMapper, documentModificationDetector, IndexWriter, context, CreateQueryable(lookup, context, documentMapper))); }
/// <summary> /// Opens a session for staging changes and then committing them atomically. /// </summary> /// <param name="factory">Factory delegate that creates new instances of <typeparamref name="T"/></param> /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param> /// <param name="documentModificationDetector">Helper to determine when instances of <typeparamref name="T"/> are modified /// and need to be updated in the index when the session is committed. /// </param> /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam> public ISession <T> OpenSession <T>(ObjectFactory <T> factory, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector) { return(OpenSession(_ => factory(), documentMapper, documentModificationDetector)); }
public SessionDocumentTracker(IDocumentModificationDetector <T> detector) { this.detector = detector; }
public override ISession <T> OpenSession <T>(ObjectLookup <T> factory, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector) { throw new InvalidOperationException("Cannot open sessions in read-only mode."); }