using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;
namespace IReaper.Command{
/// <summary>
/// ICommand
/// </summary>
class EmptyCommand : CommandBase
{
public override CommandFamily Family
{
get { return CommandFamily.Command_Empty; }
}
public override void CommandBody(object sender, params object[] paras)
{
}
}
/* 2006.8.23
* Command
* Command
*
*/
class CommandManager
{
static Dictionary<CommandFamily, CommandBase> commandlist = new Dictionary<CommandFamily, CommandBase>();
static CommandBase emptyCommand = new EmptyCommand();
static CommandManager()
{
LoadCommandFromFile();
}
private static void LoadCommandFromFile()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++)
{
Type t = types[i];
if (t.IsSubclassOf(typeof(CommandBase)))
{
CommandBase newCommand = Activator.CreateInstance(t) as CommandBase;
if (newCommand != null)
RegisteCommand(newCommand);
}
}
}
internal static CommandBase GetCommand(CommandFamily Family)
{
//
if (commandlist.ContainsKey(Family))
return commandlist[Family];
//
return emptyCommand;
}
/// <summary>
///
/// </summary>
/// <param name="Family"></param>
/// <param name="command"></param>
internal static void RegisteCommand(CommandBase command)
{
if (!commandlist.ContainsKey(command.Family))
commandlist.Add(command.Family, command);
}
}
enum CommandFamily
{
#region
Command_RemoveFile,
Command_SynchorizeCourseData,
Command_RefreshTreeNode,
Command_OpenAuthenBrowser,
Command_OpenOnDemandViedo,
#endregion
#region
Command_RevertRemind,
#endregion
#region
Command_DownloadFile,
Command_PauseDownload,
Command_OpenCourseFile,
Command_FileTransfer,
Command_ImportFiles,
#endregion
#region
Command_CloseSystem,
#endregion
#region RSS
Command_GetRssFeedFromNet,
Command_UpdateRSSFeed,
Command_RemoveRssFeed,
#endregion
Command_Empty
}
}
|