Hey all!
So I have a multiple project solution, and two of the projects are the following:
Model
- Contains base classes for all objects needed.
Utility
- Pretty much just for configuration stuff.
Now, I'm making a multiple socket server which will be listening for both user connections as well as server connections. Via the configuration file, I'd like to make the application scalable. That is, say a new server is added, then all is necessary is to update the App.config file, this is what I'm kinda looking for:
Now, I'd like to have a function in the Utility project called SlaveServers that would return a generic List of servers (which is defined in the Model layer as such):Code:<Server HostName="Socket1" IPAddress="192.168.0.10" Port="400"/> <Server HostName="Socket2" IPAddress="192.168.0.11" Port="400"/> <Server HostName="Socket3" IPAddress="192.168.0.12" Port="400"/> <Server HostName="Socket4" IPAddress="192.168.0.13" Port="400"/>
What is the best way to handle this? I know a configuration handler will need to be set (something like this I guess):Code:Imports System.Net Imports System.Configuration Public Class Server Private _hostName As String Private _ipAddress As String Private _port As Int32 Public Property HostName() As String Get Return _hostName End Get Set(ByVal value As String) _hostName = value End Set End Property Public Property IPAddress() As String Get Return _ipAddress End Get Set(ByVal value As String) _ipAddress = value End Set End Property Public Property Port() As Int32 Get Return _port End Get Set(ByVal value As Int32) _port = value End Set End Property Public Sub New() End Sub Public Sub New(ByVal inHostName As String, ByVal inIPAddress As String, ByVal inPort As Int32) _hostName = inHostName _ipAddress = inIPAddress _port = inPort End Sub End Class
Where do I go from here? I am officially stumped on how to handle this.Code:<configSections> <section name="SlaveServers" type="SocketServer.Utility.ConfigSectionHandler, SocketServer.Utility"/> </configSections>![]()




Reply With Quote