File.cs
上传用户:huiyue
上传日期:2022-04-08
资源大小:1429k
文件大小:4k
源码类别:

搜索引擎

开发平台:

ASP/ASPX

  1. using System;
  2. using System.IO;
  3. using System.Xml.Serialization;
  4. using System.Collections.Specialized;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Collections;
  8. namespace Searcharoo.Common
  9. {
  10.     /// <summary>
  11.     /// File attributes
  12.     /// </summary>
  13.     /// <remarks>
  14.     /// *Beware* ambiguity with System.IO.File - always fully qualify File object references
  15.     /// 
  16.     /// in V6 added KeywordString, GpsLocation and Extension
  17.     /// </remarks>
  18.     [Serializable]
  19.     [System.Xml.Serialization.XmlInclude(typeof(Searcharoo.Common.Location))]
  20.     public class File
  21.     {
  22.         #region Fields
  23.         [XmlIgnore]
  24.         private string _Url;
  25.         [XmlIgnore]
  26.         private string _Title;
  27.         [XmlIgnore]
  28.         private string _Extension; //[v6]
  29.         [XmlIgnore]
  30.         private string _Description;
  31.         [XmlIgnore]
  32.         private DateTime _CrawledDate;
  33.         [XmlIgnore]
  34.         private long _Size;
  35.         [XmlIgnore]
  36.         private Location _GpsLocation; //[v6]
  37.         [XmlIgnore]
  38.         private string _KeywordString; //[v6]
  39.         [XmlIgnore]
  40.         private int _IndexId; //[v7]
  41.         #endregion
  42.         [XmlAttribute("id")]
  43.         public int IndexId
  44.         {
  45.             get { return _IndexId; }
  46.             set { _IndexId = value; }
  47.         }
  48.         [XmlAttribute("u")]
  49.         public string Url
  50.         {
  51.             get { return _Url; }
  52.             set { _Url = value; }
  53.         }
  54.         [XmlAttribute("t")]
  55.         public string Title
  56.         {
  57.             get { return _Title; }
  58.             set { _Title = value; }
  59.         }
  60.         [XmlAttribute("e")]
  61.         public string Extension
  62.         {
  63.             get { return _Extension; }
  64.             set { _Extension = value; }
  65.         }
  66.         [XmlElement("d")]
  67.         public string Description
  68.         {
  69.             get { return _Description; }
  70.             set { _Description = value; }
  71.         }
  72.         [XmlAttribute("d")]
  73.         public DateTime CrawledDate
  74.         {
  75.             get { return _CrawledDate; }
  76.             set { _CrawledDate = value; }
  77.         }
  78.         [XmlAttribute("s")]
  79.         public long Size
  80.         {
  81.             get { return _Size; }
  82.             set { _Size = value; }
  83.         }
  84.         /// <summary>
  85.         /// Cannot be serialized as an XmlAttribute - it's a complex type; slightly less space-efficient
  86.         /// </summary>
  87.         [XmlElement("gps")]
  88.         public Location GpsLocation
  89.         {
  90.             get { return _GpsLocation; }
  91.             set { _GpsLocation = value; }
  92.         }
  93.         /// <summary>
  94.         /// Keyword string (comma seperated)
  95.         /// </summary>
  96.         [XmlElement("kw")]
  97.         public string KeywordString
  98.         {
  99.             get { return _KeywordString; }
  100.             set { _KeywordString = value; }
  101.         }
  102.         /// <summary>
  103.         /// Required for serialization
  104.         /// </summary>
  105.         public File() 
  106.         {
  107.             _IndexId = -1;  // [v7]
  108.         }
  109.         /// <summary>
  110.         /// Constructor requires all File attributes
  111.         /// </summary>
  112.         [Obsolete("Expects keywords, gpsLocation and extension in version 6")]
  113.         public File(string url, string title, string description, DateTime datecrawl, long length)
  114.         {
  115.             _Title = title;
  116.             _Description = description;
  117.             _CrawledDate = datecrawl;
  118.             _Url = url;
  119.             _Size = length;
  120.             _IndexId = -1;  // [v7]
  121.         }
  122.        
  123.         /// <summary>
  124.         /// Constructor requires all File attributes
  125.         /// </summary>
  126.         public File(string url, string title, string description, DateTime datecrawl, long length
  127.             , Location gpsLocation
  128.             , string extension
  129.             , string keywords)
  130.         {
  131.             _Title = title;
  132.             _Description = description;
  133.             _CrawledDate = datecrawl;
  134.             _Url = url;
  135.             _Size = length;
  136.             _GpsLocation = gpsLocation;
  137.             _Extension = extension;
  138.             _KeywordString = keywords;
  139.             _IndexId = -1;  // [v7]
  140.         }
  141.         /// <summary>
  142.         /// Debug string
  143.         /// </summary>
  144.         public override string ToString()
  145.         {
  146.             return "tFILE " + IndexId + " :: " + Url + " -- " + Title + " - " + Size + " bytes + nt" + Description + "n";
  147.         }
  148.     }
  149. }