private static Object CreateChannelSinkProvider(RemotingXmlConfigFileData.SinkProviderEntry entry,
bool bServer)
{
Object sinkProvider = null;
Type type = RemotingConfigInfo.LoadType(entry.TypeName, entry.AssemblyName);
if (bServer)
{
// make sure this is a client provider
if (!typeof(IServerChannelSinkProvider).IsAssignableFrom(type))
{
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_InvalidSinkProviderType"),
type.FullName,
"IServerChannelSinkProvider"));
}
}
else
{
// make sure this is a server provider
if (!typeof(IClientChannelSinkProvider).IsAssignableFrom(type))
{
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_InvalidSinkProviderType"),
type.FullName,
"IClientChannelSinkProvider"));
}
}
// check to see if something labelled as a formatter is a formatter
if (entry.IsFormatter)
{
if ((bServer && !typeof(IServerFormatterSinkProvider).IsAssignableFrom(type)) ||
(!bServer && !typeof(IClientFormatterSinkProvider).IsAssignableFrom(type)))
{
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_SinkProviderNotFormatter"),
type.FullName));
}
}
// setup the argument list and call the constructor
Object[] args = new Object[2];
args[0] = entry.Properties;
args[1] = entry.ProviderData;
try
{
sinkProvider = Activator.CreateInstance(type,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.CreateInstance,
null,
args,
null,
null);
}
catch (MissingMethodException)
{
throw new RemotingException(
String.Format(
CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Config_SinkProviderMissingCtor"),
type.FullName,
"MySinkProvider(IDictionary properties, ICollection providerData)"));
}
return sinkProvider;
} // CreateChannelSinkProvider