📄 enginesetting.cs
字号:
using System;
using System.Text;
using System.Collections;
namespace SECompare.Structure
{
/// <summary>
/// Enumaration of all search engines supported by this application.
/// </summary>
public enum EngineSet{Google,MSN,Yahoo};
//-----------------------NOTICE------------------------
//If you want to add more engines, please modify here.
//-----------------------------------------------------
/// <summary>
/// Get seetings of search engine.
/// </summary>
public class EngineSetting
{
/// <summary>
/// Select status of all the supported engines.
/// If it is selected, it is contained in the Hashtable, else not contained.
/// </summary>
private Hashtable SelectStatus;
public String[] SelectedEngines
{
get
{
String[] retval = new String[this.SelectStatus.Count];
int i = 0;
IDictionaryEnumerator enumer = this.SelectStatus.GetEnumerator();
while(enumer.MoveNext())
retval[i++] = (String)enumer.Key;
return retval;
}
}
public EngineSetting()
{
this.SelectStatus = new Hashtable(5);
this.SetDefault();
}
private void SetDefault()
{
this.SelectStatus.Clear();
this.Select(EngineSet.Google);
this.Select(EngineSet.MSN);
}
public bool IsSelected(EngineSet engine)
{
return this.SelectStatus.Contains(engine.ToString());
}
public void Select(EngineSet engine)
{
this.Select(engine.ToString());
}
public void Select(String engine)
{
if(!this.SelectStatus.Contains(engine))
this.SelectStatus.Add(engine,true);
}
public void DisSelect(EngineSet engine)
{
this.DisSelect(engine.ToString());
}
public void DisSelect(String engine)
{
if(this.SelectStatus.Contains(engine))
this.SelectStatus.Remove(engine);
}
public override string ToString()
{
StringBuilder buf = new StringBuilder();
IDictionaryEnumerator enumer = this.SelectStatus.GetEnumerator();
while(enumer.MoveNext())
buf.Append(enumer.Key + " | ");
buf.Remove(buf.Length-2,2);
return buf.ToString();
}
/// <summary>
/// Max records count could be gotten per query.
/// This is determined by search engines themselves.
/// </summary>
/// <param name="Engine">Engine Type</param>
/// <returns></returns>
public static int GetRecordPerQuery(EngineSet Engine)
{
//-----------------------NOTICE------------------------
//If you want to add more engines, please modify here.
//-----------------------------------------------------
switch(Engine)
{
case EngineSet.Google:
return 100;
case EngineSet.MSN:
return 50;
case EngineSet.Yahoo:
return 100;
default:
return 50;
}
}
/// <summary>
/// Max rank could be gotten using public web search interface.
/// </summary>
/// <param name="Engine"></param>
/// <returns></returns>
public static int GetMaxRank(EngineSet Engine)
{
//-----------------------NOTICE------------------------
//If you want to add more engines, please modify here.
//-----------------------------------------------------
switch(Engine)
{
case EngineSet.Google:
return 1000;
case EngineSet.MSN:
return 250;
case EngineSet.Yahoo:
return 1000;
default:
return 250;
}
}
/// <summary>
/// Parse engine name from string to EngineSet type.
/// </summary>
/// <param name="EngineName">Engine Name</param>
/// <returns></returns>
public static EngineSet GetEnum(String EngineName)
{
return (EngineSet)Enum.Parse(typeof(EngineSet),EngineName,true);
}
/// <summary>
/// Get an array of all the supported engine names.
/// </summary>
/// <returns>Engine names list</returns>
public static String[] GetEngines()
{
String[] ret = new String[Enum.GetValues(typeof(EngineSet)).Length];
int k = 0;
foreach(int i in Enum.GetValues(typeof(EngineSet)))
{
ret[k] = Enum.GetName(typeof(EngineSet),i);
k++;
}
return ret;
}
/// <summary>
/// Get an array of all the supported engine enumarator indice.
/// </summary>
/// <returns>Engine Enumarator indice list</returns>
public static EngineSet[] GetEngineEnums()
{
EngineSet[] ret = new EngineSet[Enum.GetValues(typeof(EngineSet)).Length];
int k = 0;
foreach(int i in Enum.GetValues(typeof(EngineSet)))
{
ret[k] = EngineSetting.GetEnum( Enum.GetName(typeof(EngineSet),i) );
k++;
}
return ret;
}
/// <summary>
/// Get Engine name.
/// </summary>
/// <param name="Engine">Engine of enum style</param>
/// <returns>Engine name</returns>
public static String GetName(EngineSet Engine)
{
return Engine.ToString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -