using System; using System.Collections.Generic; using System.Text; using ScrewTurn.Wiki.SearchEngine; namespace ScrewTurn.Wiki { /// /// Represents a file document. /// public class FileDocument : IDocument { /// /// The type tag for a . /// public const string StandardTypeTag = "F"; private uint id; private string name; private string title; private string typeTag = StandardTypeTag; private DateTime dateTime; private string provider; /// /// Initializes a new instance of the class. /// /// The file full name. /// The file provider. /// The modification date/time. public FileDocument(string fullName, string provider, DateTime dateTime) { if(fullName == null) throw new ArgumentNullException("fullName"); if(fullName.Length == 0) throw new ArgumentException("Full Name cannot be empty", "fullName"); if(provider == null) throw new ArgumentNullException("provider"); if(provider.Length == 0) throw new ArgumentException("Provider cannot be empty", "provider"); id = Tools.HashDocumentNameForTemporaryIndex(fullName); name = provider + "|" + fullName; title = fullName.Substring(Tools.GetDirectoryName(fullName).Length); this.dateTime = dateTime; this.provider = provider; } /// /// Initializes a new instance of the class. /// /// The dumped document. public FileDocument(DumpedDocument doc) { string[] fields = doc.Name.Split('|'); id = doc.ID; name = doc.Name; title = doc.Title; dateTime = doc.DateTime; provider = fields[0]; } /// /// Gets or sets the globally unique ID of the document. /// public uint ID { get { return id; } set { id = value; } } /// /// Gets the globally-unique name of the document. /// public string Name { get { return name; } } /// /// Gets the title of the document, if any. /// public string Title { get { return title; } } /// /// Gets the tag for the document type. /// public string TypeTag { get { return typeTag; } } /// /// Gets the document date/time. /// public DateTime DateTime { get { return dateTime; } } /// /// Performs the tokenization of the document content. /// /// The content to tokenize. /// The extracted words and their positions (always an empty array). public WordInfo[] Tokenize(string content) { return ScrewTurn.Wiki.SearchEngine.Tools.Tokenize(content); } /// /// Gets the provider. /// public string Provider { get { return provider; } } } }