Domanda

I have a little problem understanding what I should do.

I have a main project MainProj.
And another project called PluginHandler who has an IPlugin interface.

What I'm trying to achieve is to "send" an object called Network from MainProj to each plugin that implement the IPlugin interface.

My problem is what type should I write in the IPlugin, because it's in a different project I can't just say Network - and I can't reference it because I need a reference to the PluginHandler in the MainProj, in order to instantiate each plugin (using reflections)

Any ideas?

È stato utile?

Soluzione

You need to create a "shared library". So instead of

  • MainProj
    • Network
  • PluginHandler
    • IPlugin
  • Plugin

you should have

  • MainProj
  • PluginHandler
    • IPlugin
  • Plugin
  • Common
    • Network

So you place the Network class inside the Common project and reference this by all other projects.

Altri suggerimenti

You just need to add the other project as a reference in your MainProj and then add a using statement to import that namespace into your file.

When adding a reference you can either choose a dll or just choose another project.

How to add a reference

How to add a using statement

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top