public void AddDefaultParsers()
{
string ns = GetType().Namespace + ".Parsers";
Type parserInterface = typeof (IHeaderParser);
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
{
if (type.Namespace != ns)
continue;
if (!parserInterface.IsAssignableFrom(type))
continue;
if (type.IsInterface || type.IsAbstract)
continue;
var parser = (IHeaderParser) Activator.CreateInstance(type);
foreach (object attr in type.GetCustomAttributes(false))
{
// Generic parser should not be added automatically.
if (attr is GenericParserAttribute)
break;
var attribute = attr as ParserForAttribute;
if (attribute != null)
AddParser(parser, attribute.Name, attribute.CompactName);
}
}
}