I've been decompiled an aplication to learn about how they handle command. But I do not know exactly what type of the following file.because the file is inherit from superclass that inherit from system.windows.forms.component but also this file have resource (ExploreCommand.Resx) file in reflector.

Resource save image and string to execute command.
Code :
[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 ", "");
        }
    }
AND THIS THE SUPERCLASS :
[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();
    }


}
sOMEBOY CAN help me please....
lopin123
0

Comments

3 comments

  • haleyjason
    What about the base class's GetCommandForCaller method?

    Without seeing everything, my guess is they have done one of the following:
    1. stored either serialized code in those resources that they are just extracting and handing back as a command to execute

    2. stored binaries in the resources to be extracted and executed as needed

    There are other options as well, but my guess would be #1 above. If you look into the GetCommandForCaller it should help.
    haleyjason
    0
  • lopin123
    #haleyJason
    Thanks for your quick response. This the Code for GetCommandForCaller :
    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;
        }
    

    so I can't create ExploreCommand.resx manualy? what do you think?
    lopin123
    0
  • haleyjason
    Can you create it manually? That depends on what you mean by 'create'. Are you looking to use their code (via reference) or are you trying to build something like it (via inspiration)?

    If you're referencing there code, then that shouldn't be a problem.

    If you're using the code for inspiration for your own implementation, then you'll really need to understand what they are doing before you will be able to just create your own ... but I'm guessing you knew that.
    haleyjason
    0

Add comment

Please sign in to leave a comment.