What about some refactoring?
When you work with configuration files throughout the framework and the application blocks, you encounter assembly qualified names. Assembly qualified names (AQN) look like this: "MyNamespace.MyClass, MyAssembly". This is useful, because a string like this gives you everything you need to find a type. You can simply use Type.GetType() to access a type, based on its AQN.
I was searching for a method to parse AQNs for my own
configuration files because I need to call
Activator.CreateInstance(string, string), which expects assembly name and type name broken
apart.
Well, I looked in the framework, and I found
several methods.
There is
Assembly.ParseTypeName(). There is
TypeInfo.ParseTypeAndAssembly(). There is
RemotingXmlConfigFileParser.ParseType().
The
first one is internal to the CLR, the others have
implementations of their own. Maybe more implementation are
scattered around the framework, and maybe more in
application blocks or other apps.
I'd say it's time for some refactoring to
create one and only method in the framework. It's not
because writing this method is difficult, but it's violating
the
DRY principle. What if AQNs change in .NET 3.2?
It would be nice if
this method gets public too so we don't have to write our
own...
