19 using System.Configuration;
21 using System.Reflection;
22 using System.Runtime.Serialization;
23 using System.Runtime.Serialization.Formatters.Binary;
24 using Lucene.Net.Analysis;
25 using Lucene.Net.Documents;
26 using Lucene.Net.Distributed;
28 namespace Lucene.Net.Distributed.Indexing
45 public static BinaryFormatter Formatter =
new BinaryFormatter();
46 private static string filepath = (ConfigurationManager.AppSettings[
"IndexDocumentPath"] != null ? ConfigurationManager.AppSettings[
"IndexDocumentPath"] :
"");
47 private static string endwhack = (filepath.EndsWith(
@"\") ?
"" :
@"\");
48 private DateTime _eDateTime;
66 this._intRecordId = iRecordId;
68 this._eDateTime = DateTime.Now;
71 public IndexDocument(
Document oDocument,
int iRecordId)
73 this._oDocument = oDocument;
74 this._intRecordId = iRecordId;
75 this._eDateTime = DateTime.Now;
83 get {
return this._oDocument;}
88 get {
return this._intRecordId;}
91 public virtual Analyzer GetAnalyzer()
96 public string FileName
98 get {
return Environment.MachineName +
"_" + this.GetType().ToString() +
"_" + this.RecordId.ToString() +
"_" + this.DateTime.Ticks.ToString() +
".bin"; }
100 private DateTime DateTime
102 get {
return this._eDateTime; }
112 FileStream fs = File.Open(filepath + endwhack + this.FileName, FileMode.Create, FileAccess.ReadWrite);
113 IndexDocument.Formatter.Serialize(fs,
this);
116 catch (SerializationException se)
120 catch (NullReferenceException nre)
125 public void Save(
string filePath)
129 FileStream fs = File.Open(filePath + endwhack + this.FileName, FileMode.Create, FileAccess.ReadWrite);
130 IndexDocument.Formatter.Serialize(fs,
this);
133 catch (SerializationException se)
137 catch (NullReferenceException nre)