One thing we have found useful over the years is to wrap a service proxy in a public interface Dynamic Link Library. Though this in one sense may contradict the idea of Service Oriented Architecture (SOA); in another sense it holds up the idea of refactoring.
In this project, we have created a singleton that loads the configuration file from the database. Furthermore, this singleton aggregates Windsor Container for easy of accessibility throughout ones program. One draw back is (depending on usage) the load time of ones program may suffer due to Service / Database Access.
Previously, we stated that DBinsor required each class to implement an interface. Thus, we ensured this by added our custom resolve method in the singleton.
public T Resolve<T, S>()
where T : class, S
{
return this._container.Resolve<S>(typeof(T).ToString()) as T;
}
In future releases of this library, we will add more methods to the singleton to provide access to other functionality of the Windsor Container.
Again, we used the factory methodology to allow for multiple sources for the Windsor Container. That is, we plan to allow a user to pick from our database service, an application configuration file, a web configuration file or a standalone xml file as their source for the singleton.
The public interface uses the “app.config” or the “web.config” files for three things: lookup name, resource source and service binding. Here is a sample:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="LookupName" value="Test1" />
<add key="ResourceSource" value="Database" />
</appSettings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ConfigSvcEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:3837/DBinsor.Svc.WCF.Host/Configuration.svc"
binding="basicHttpBinding" bindingConfiguration="ConfigSvcEndPoint"
contract="ConfigurationServiceProxy.ConfigurationServiceContract"
name="ConfigSvcEndPoint" />
</client>
</system.serviceModel>
</configuration>