我已经反编译了一个应用程序 exe,以了解它们如何处理命令。但我不知道以下文件的确切类型。因为该文件是从继承自 system.windows.forms.component 的超类继承的,而且该文件在反射器中有资源(ExploreCommand.Resx)文件。
[DesignerCategory("Accurate Command Binders"), ToolboxItem(true), DesignTimeVisible(true)]
internal class ExplorerCommands : CommandBinder
{
// Fields
private static readonly ResourceManager resources = new ResourceManager(typeof(ExplorerCommands));
// Methods
protected ExplorerCommands()
{
}
public ExplorerCommands(Control control) : base(control)
{
}
// Properties
[Browsable(false)]
public Command AboutAccurate {
get
{
return base.GetCommandForCaller("AboutAccurate ", "CitraKarya.Bisnis.Akunting.UI.Explorer.AboutAccurate ", "");
}
}
在使用此类的每个表单上,他们都这样声明:
this.reportCommands = new CitraKarya.Akunitng.UI.ReportCommands(this);
但我不知道命令类是如何创建的。它们的语法与资源类不同。有谁能够帮我?这是什么意思?以及如何实施这个案例?
哦..这是 exploreCommand 的基类:
代码:
[DesignerCategory(""), DesignTimeVisible(false), Designer(typeof(CommandBinderDesigner), typeof(IDesigner)), ProvideProperty("Command", typeof(object)), TypeConverter(typeof(CommandBinderTypeConverter)), ToolboxItem(false)]
public abstract class CommandBinder : Component
{
// Methods
protected CommandBinder()
{
this.commands = new Dictionary<object, Command>();
this.InitializeComponent();
}
protected CommandBinder(Control parentControl)
{
this.commands = new Dictionary<object, Command>();
this.parentControl = parentControl;
IComponent component = parentControl;
if ((component.Site != null) && (component.Site.Container != null))
{
component.Site.Container.Add(this);
}
this.InitializeComponent();
}
protected Command GetCommandForCaller(string propertyName, string id, string category)
{
CommandManager commandManager = CommandManager;
Command command = null;
if (commandManager != null)
{
command = commandManager.Commands[id];
}
if (command == null)
{
command = CreateCommand(propertyName, id, category);
if (commandManager != null)
{
commandManager.Commands.Add(command);
return command;
}
CommandsToBeAdded.Add(command);
}
return command;
}
}