/// <summary>
/// This handles running through the configuration and getting the request
/// and response processors.
/// </summary>
/// <param name="config">The config file we are using.</param>
/// <param name="sectionName">The config section we are using to look for RequestProcessors and ResponseProcessors.</param>
private void GetProcessors(Config config, string sectionName)
{
if (config.ComponentExists(sectionName))
{
IList<KeyValuePair<string, string>> kvps = config.GetParametersAsList(sectionName);
foreach (KeyValuePair<string, string> kvp in kvps)
{
string typeName = kvp.Value;
Type processorType = Type.GetType(typeName);
if (processorType != null && typeof(IProcessor).IsAssignableFrom(processorType))
{
ConstructorInfo ci = processorType.GetConstructor(new [] {typeof (Config), typeof (string)});
IProcessor p;
if (ci != null)
{
p = (IProcessor) ci.Invoke(new object[] {config, kvp.Key});
}
else
{
ci = processorType.GetConstructor(new Type[] {});
if (ci == null)
{
throw new ConfigurationErrorsException("Processor '" + typeName +
"' was specified, but we were unable to get constructor info.");
}
p = (IProcessor) ci.Invoke(new object[] {});
}
// At this point we have a processor object. Add it to the dictionary.
if (p as IRequestProcessor != null)
{
_processors[typeof (IRequestProcessor)].Add(p);
}
if (p as IResponseProcessor != null)
{
_processors[typeof (IResponseProcessor)].Add(p);
}
}
}
}
}