Пример #1
0
        /// <summary>
        /// Handles the <see cref="IInMemoryIndex.IndexChanged" /> events.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments.</param>
        protected void IndexChangedHandler(object sender, IndexChangedEventArgs e)
        {
            lock (this)
            {
                if (_disposed)
                {
                    return;
                }

                switch (e.Change)
                {
                case IndexChangeType.IndexCleared:
                    InitDataStore(e.State);
                    break;

                case IndexChangeType.DocumentAdded:
                    if (!_dataCorrupted)
                    {
                        IndexStorerResult result = SaveData(e.ChangeData, e.State);
                        e.Result = result;
                    }
                    break;

                case IndexChangeType.DocumentRemoved:
                    if (!_dataCorrupted)
                    {
                        DeleteData(e.ChangeData, e.State);
                    }
                    break;

                default:
                    throw new NotSupportedException("Invalid Change Type");
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Takes care of firing the <see cref="IndexChanged" /> event.
 /// </summary>
 /// <param name="document">The affected document.</param>
 /// <param name="change">The change performed.</param>
 /// <param name="changeData">The dumped change data.</param>
 /// <param name="state">A state object that is passed to the IndexStorer SaveDate/DeleteData function.</param>
 /// <returns>The storage result or <c>null</c>.</returns>
 protected IndexStorerResult OnIndexChange(IDocument document, IndexChangeType change, DumpedChange changeData, object state)
 {
     if (IndexChanged != null)
     {
         IndexChangedEventArgs args = new IndexChangedEventArgs(document, change, changeData, state);
         IndexChanged(this, args);
         return(args.Result);
     }
     else
     {
         return(null);
     }
 }