After we made the application working, the next step is to make it configurable, so a user won’t need to recompile the program when he wants to add or modify a host.
This step is rather easy to implement, although personally I don’t like .NET configuration and prefer INI-files based one, in this particular scenario I’m choosing the standard one. So, in order to map a collection of HostViewModel items, I’ve added HostConfigurationElement, HostConfigurationElementCollection & MainSection types. While working on this task, I’ve found absolutely fabulous and useful .NET configuration guide, which I recommend to everyone. The guide consists of 3 big parts: Unraveling, Decoding & Cracking the Mysteries of .NET 2.0 Configuration, don’t miss it.
So, having configuration-related types done, I got the ability to move host-related data to application configuration file:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="NetMonitor.Main" type="NetMonitor.Configuration.MainSection, NetMonitor, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null" /> </configSections> <NetMonitor.Main> <hosts> <host name="Wi-Fi Router" address="192.168.1.1"/> <host name="Gate" address="10.1.8.2"/> <host name="VPN Server" address="10.0.0.66"/> <host name="DNS Server" address="10.0.0.1"/> <host name="Google" address="google.com"/> <host name="Yahoo" address="yahoo.com"/> </hosts> </NetMonitor.Main> </configuration>
After the application has been made configurable, it might become useful not only for me, but for somebody else. Therefore, I’ve built it and uploaded here for those who might be interested in using it. In this public version I removed personal hosts such as wi-fi router, gate, etc., because they don’t make any sense to anyone, except me.
Next time I’m going to make some changes to the UI, as there are tons of tasks to be done to get really useful piece of software, even to this tiny one.