Sign in to follow this  
GameMasterXL

C# Interfaces

Recommended Posts

Ok here is my problem say i have an assembly caled test and in that a folder called x and in that a public class called foo and in that a public static object called bar so in my interface that would look like
public interface
{
  test.x.foo.bar;
}

But it won't allow the above at all and allways wants it in a function but i want my class objects which in that example would be in foo to be globaly accessible to plugin programmers since this is for a plugins system. This is used so i can expand on menus and add stuff to all ready made components in my program but the interfaces will not allow me this without putting it in a function which will not work like i want it to. Does anyone know of a solution to this? i searched all over but found nothing similar, thnx in advance.

Share this post


Link to post
Share on other sites
An interface in C# is a description of what a class is expected to be capable of doing; interfaces are meant to be used in conjunction with classes. More information is available here and here (note the table of contents on the left).


What you want is probably a namespace. This should at least get you going in the right direction. I'm assuming that your bar object is of type BarType:

namespace TestPluginLink
{
public BarType GetBar()
{
return test.x.foo.bar;
}
}


This of course assumes that bar is accessible to the TestInterface code.


Hope that helps clarify things a bit.

Share this post


Link to post
Share on other sites
Quote:
Original post by ApochPiQ
What you want is probably a namespace. This should at least get you going in the right direction. I'm assuming that your bar object is of type BarType:

namespace TestPluginLink
{
public BarType GetBar()
{
return test.x.foo.bar;
}
}




Or even:


namespace Test
{
namespace X
{
public interface Foo
{
BarType Bar
{
get;
}
}

}
};


Of course, then you'd need to implement it.

Share this post


Link to post
Share on other sites
Ah thnx for that but this is in a seperate .dll file so the interface will be for what every plugin needs to impliment but i want that interface.dll to give global definations of objects which my main programs assembly is linked within interfaces.dll so like i have linked my program to it and i am trying to make a class in my assembly accessable through my interface in my .dll file for plugin programmers. So i can add new features to an all ready made menu for instance etc but currently it won't let me. Now the other thing i thought is for the plugin itself to impliment my assembly and do it like that adding stuff and use the plugin interface.dll file to give general information about the plugin etc but then that defys the point of a plugin system :(.

Share this post


Link to post
Share on other sites
I can aaccess everything in my main host program currently i just want to be able to use objects from my main host program in my plugin interfaces assembly so i can access them through a plugin like if i wanted to add a menu item to a menu in my host program i would like to be able to access the main object from my plugin interface assembly like for instance.

my plugin interface will be called Interfaces.dll which stores an interface for showing the plugins name, version, author, description, icon etc and some intialize and dispose functions which my main host program calls. But i want to make objects which are in my main program global in my interfaces.dll file so that plugins can use them like


// inside some function here to add a menu item
myprogram.myfolder.myclass.x; // this being used through interfaces.dll and not direct through my program



I could now make a plugin interface.dll which only gives my plugins basic information to display to the host and link the host program direct to the plugin and use the host that way but that will defy the point of using a plugin for that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this