コマンドの処理方法について学ぶために、アプリケーション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;
}
}