たとえば、.NET app.config では、次のようになります。
<configuration>
<configSections>
<section name="MyConfig" type="MyAssembly.MyType, MyAssembly, PublicKeyToken=null" />
</configSections>
...
</configuration>
型部分の署名は、さまざまな .NET の場所で標準化されているようですが、自分のプログラム内でこれを行う方法がわかりません。私は自分のプログラムで使用System.Activator
しましたが、.NET が既に行っている作業を複製しているように感じます。
プログラミング用語では、これを行う方法は次のとおりです。
void Main()
{
object instance = CreateInstance("MyAssembly.MyType, MyAssembly, PublicKeyToken=null");
Console.WriteLine(instance.GetType().Name);
}
object CreateInstance(string dotNetTypeSignature)
{
// Code goes here.
}