At startup, I load all of my app.config values ββinto a class named ConfigValues. My database only needs some of them, so I have an interface IDatabaseConfigthat specifies only those parameters that it needs. Thus, when I create a database connection class, with a constructor injector, I can require that everything that implements be passed to it IDatabaseConfig.
I would like to declare several interfaces in a class ConfigValuesand allow some properties to execute several contracts at the same time.
Here is an example of a little code:
Public Interface IAppConfig
Property Server As String
Property ErrorPath As String
End Interface
Public Interface IDatabaseConfig
Property Server As String
End Interface
Public Class ConfigValues
Implements IAppConfig
Implements IDatabaseConfig
Public Property ErrorPath As String Implements IAppConfig.ErrorPath
'need different syntax - does not compile:
Public Property Server As String Implements IAppConfig.Server,
Implements IDatabaseConfig.Server
End Class
In VB.NET, is there a way to indicate that a single property satisfies a contract for multiple interfaces?
SO, .
, , backing, , API.
Private _server As String
Public Property ServerForApp As String Implements IAppConfig.Server
Get
Return _server
End Get
Set(value As String)
_server = value
End Set
End Property
Public Property ServerForDatabase As String Implements IDatabaseConfig.Server
Get
Return _server
End Get
Set(value As String)
_server = value
End Set
End Property