This project has moved. For the latest updates, please go here.

How to use it (Simplest form)

Server
The server included in the project is very small and simple; it includes only three files.

- NadaConfig.dll (the nadaconfig library)
- NadaServer.exe (the server itself)
- NadaServer.exe.config (the configuration file)

In the config file, there is an 'Environments' section; this is where you define the environments that your server will provide configuration for.
Each environment includes sections and configuration items; this is where you set the configuration data that your server will serve.

Just start the executable and you are done on the server side. Make sure that the firewall is open for the port that is set for the baseAddress in the config file. You can also change the port in the config file if you need to.

Environments Config Example
  <Environments>
    <Environment name="Production">
      <Sections>
        <Section name="Database">
          <Item name="test" value="123" />
          <Item name="test1" value="123" />
          <Item name="test3" value="123" />
          <Item name="test5" value="123" />
          <Item name="test7" value="123" />
        </Section>
        <Section name="Server">
          <Item name="test" value="toto"/>
        </Section>
      </Sections>
    </Environment>
    <Environment name="Training">
      <Sections>
        <Section name="Database">
          <Item name="test" value="1234" />
          <Item name="test8" value="1236" />
          <Item name="test9" value="1238" />
          <Item name="test10" value="1239" />
          <Item name="test11" value="1230000" />
        </Section>
        <Section name="Server">
          <Item name="test" value="toto"/>
        </Section>
      </Sections>
    </Environment>
  </Environments>


Client
For the client there is two options:
  1. Add a reference to the NadaConfig assembly in your project (you will need the NadaConfig.dll at runtime)
  2. Add the NadaConfigClient.cs file to your project and add a reference to the System.ServiceModel .net assembly (you won't need the dll; all the code will be in your binary)

In your code, create an instance of NadaConfigClient.NadaClient passing the environment name as the parameter. You can validate that you found the server by checking the 'isConnected' property to make sure that you did not get a timeout.
Just call 'GetConfigItem(section_name, item_name)' to get a configuration item. That's it; like i said before, simple and easy....

Example
using NadaConfigClient;

public void test()
{
	NadaClient client;
	client = new NadaClient(@"Production');
	if(client.isConnected)
	{
		string dbConnectString = client.GetConfigItem(@"Database", @"ConnectString");
	}
}


In some network configuration (firewall, switches etc) the automatic discovery does not always function properly; so there is a constructor where you can provide the server name as well to force a connection on a specific server. (It will still use mailslots to recover the wcf service name, address, port etc)

If for performance issues, you want to totally disable the service discovery (not using mailslots at all). There is a constructor where you can provide the service endpoint address. The client will then automatically sends all its requests to that address.

Back To Documentation

Last edited Aug 29, 2011 at 8:06 PM by jmjulien, version 6

Comments

No comments yet.