SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Call an addin from the base

Last post 07-04-2008 9:15 AM by elgrazo. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 06-23-2008 3:43 PM

    Call an addin from the base

    Hi

    I think I missed a very important part of the add-in functionality in i#sharpcode. I have the base add-in which contains the main form. In this main form there is another form for managing addresses. I have then created an add-in for managing campaigns which has it's own win form.

    And now my question: How can I call my add-in win form from the base without adding a reference to the add-in (loose coupling)?

    Thank you for your help!

    Mike

    Filed under:
  • 06-23-2008 4:18 PM In reply to

    Re: Call an addin from the base

    Well, the main idea of add-ins is that they are optional / multiple add-ins can be installed - so it doesn't make sense to call a specific addin.

    The base add-in can call extensible functionality by building objects from the add-in tree and calling a method on them:

                foreach (ICommand command in AddInTree.BuildItems<ICommand>("/Some/Path", null, false)) {
                    command.Run();
                }

    AddIns can register "ICommand" objects like this:

        <Path name = "/Some/Path">
            <Class id = "MyID"
                   class = "MyAddIn.SomeCommand"/>
        </Path>

    You can use any interface, ICommand is just an example.

    Daniel Grunwald
  • 06-25-2008 11:16 AM In reply to

    Re: Call an addin from the base

    Hi Daniel

    OK, thank you for your help. I'll try it this way.

    Mike 

  • 07-03-2008 3:11 PM In reply to

    Re: Call an addin from the base

    Hi  there,

    I'm just trying to use the Builditems-Method as described but I still didn't get it to work.

    By debugging I could trace the Problem to the "return asm.CreateInstance(instance);"-Line in the CreateInstance-Method of the Runtime-Class.

    I get 'null' returned even if the instance-variable is a valid classname. 

     

    The use of the Builditems-Method looks like this: 

    ArrayList test = AddInTree.BuildItems("/Controllers/CampaignAdministration", null,true);

     

    The Path looks like this: 

      <Path name="/Controllers/CampaignAdministration">
        <Class id="GoogleAdwords"
               class="Arcos.ERP.Addin.CampaignAdministration.GoogleAdwords"/>
      </Path>

     

     And the codon:

      public class GoogleAdwords : AbstractCommand
        {
           
            public GoogleAdwords() {
                lala = "mumu"; //The string-property is just here to test if the constructor is called

            }
           
            public string lala { get; set; }

            public override void Run()
            {
                throw new NotImplementedException();
            }
        }

     

    When checking the path in the addintree, the codon is perfectly registered.

     

    Is there something additional i forgot?

     

     

  • 07-03-2008 4:42 PM In reply to

    Re: Call an addin from the base

     Maybe you're not looking for the class is the right assembly?

    ICSharpCode.Core will look for classes in the assemblies referenced in the <Runtime> section of the .addin file.

    Daniel Grunwald
  • 07-04-2008 9:15 AM In reply to

    Re: Call an addin from the base

     Hi Daniel,

    Thanks for the quick reply. I wish it was just that...

    But there's just 1 assembly, thus it can't be on the wrong place. Furthermore there's also another MenuItem on the same place which works.

     

    EDIT: OK, problem solved, sometimes taking a break is enough to see that Addin and AddIn is not the same thing... :(

Page 1 of 1 (6 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.