I am currently coding a set of helper classes to be used when creating a proxy client[for Client/Silverlight use] for consuming WCF services on the Server (NOT using Add Service Reference).
Notice how I am setting up the buffer size to the max allowed (on the first code snippet), because for some services we have some big payload requirements. The secundary effect is that now, I have to setup the WCF service to share the same buffer size with the proxy client, so that they are in sync. I don't want to have to enter these numbers in a configuration file (one on the client, one on the server); instead I want to share some kind of configuration object for both, so that I only change the settings once.
My initial idea is creating a static class with static readonly fields as configuration items, to provide easy access to each configuration set, as well as intellisense integration. Any thoughts or recommendations?
// .... First code snippet
BasicHttpBinaryBinding binding = new BasicHttpBinaryBinding ();
// Increase the buffer sizes to the limit
binding.MaxBufferSize = Int32.MaxValue; // <------- HARD CODED
binding.MaxReceivedMessageSize = Int32.MaxValue; // <------- HARD CODED
EndpointAddress endPoint = new EndpointAddress(
string.Format ( "{0}{1}", _baseUri, string.Format ( BASE_SERVICE, serviceName ) ) );
//......................
/* CONFIGURATION CLASSES */
public class BindingBufferConfiguration
{
public int MaxBufferSize { get; protected set;}
public int MaxReceivedMessageSize { get; protected set; }
public BindingBufferConfiguration (int MaxBufferSize,int MaxReceivedMessageSize)
{
this.MaxBufferSize = MaxBufferSize;
this.MaxReceivedMessageSize = MaxReceivedMessageSize;
}
}
public static class PatientModuleBufferConfiguration
{
public static readonly BindingBufferConfiguration PatientProxyBufferConfiguration = new BindingBufferConfiguration ( 4096, 4096 );
public static readonly BindingBufferConfiguration PatientPhotoProxyBufferConfiguration = new BindingBufferConfiguration(1024 * 500 /*500 KB*/,1024 * 500 /*500 KB*/ )
// ....
}