Require shared member implementation using Interfaces

  • Thread starter Thread starter Rubbrecht Philippe
  • Start date Start date
R

Rubbrecht Philippe

Hi there,

I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It seems
a Shared Member can not be used as interface member implementation?!

Is there a workaround to this problem?!

Best regards,
Philippe Rubbrecht
 
This is not a problem, you are just looking at it from the wrong
perspective. When you choose to implement and interface, you are making a
statement that 'I will implement this interface', the paramaters passed to
the functions/sub and those returned by the functions are external to the
class. Any implementation which is done in the class which 'Implements' this
interface is up to the class designer.

You on the other hand seem to be suggesting that the interface itself has an
implementation. Interfaces can have the following defined; Properties,
Events, Members or Types.

Maybe I have misunderstood you, if after reading this reply you think I have
could you be more specific



--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
Let me give you a small example of what I'm trying to do:

I want every assembly that is developed in my team to provide an
"AssemblyInfo" class that provides a number of properties and methods for
that assembly. For example, I want a SHARED Property or Function
"Environment" to be available that states the name of the environment
(Development, Test, Acceptance or Production) that the assembly is currently
running in.

Therefore I tried to develop an interface "IAssemblyInfo" that needs to be
implemented in every assembly to make sure that these properties and methods
become available.

However, the class that implements this interface can not define this
implemented property of function to be Shared!
It seems to be impossible to have Shared members as an interface member
implementation!?
 
Yes thats correct. Interfaces do not have any implementation, they are
simply templates. For example, you cannot define a member variable, only a
property, your member functions and subs can only be signatures and may not
have implementation.

Why not create a class library which return these values which are
applicable to the assembly, and have them stored in the App.config. file as
a value/key pair. This way you only need add a reference to your assembly
and ensure that the values are in the config file.



--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
* "Rubbrecht Philippe said:
I would like to develop an interface that when implemented in a class
requires a number of shared properties or methods to be available. It seems
a Shared Member can not be used as interface member implementation?!

This scenario cannot be described using VB.NET syntax. Notice that
shared members cannot be overridden.
 
Back
Top