Reflection to the rescue!
List<string> allEnums = new List<string>();
var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(assembly => assembly.GetTypes());
foreach (Type type in allTypes)
{
if (type.Namespace == "MyCompany.SystemLib" && type.IsEnum)
{
string enumLine = type.Name + ",";
foreach (var enumValue in Enum.GetValues(type))
{
enumLine += enumValue + "=" + ((int)enumValue).ToString() + ",";
}
allEnums.Add(enumLine);
}
}
The first line goes over all assemblies currently loaded in memory (because a namespace can be scattered over many DLLs and EXEs) and filters out those in the right namespace, and that are enums. This can be streamlined into a LINQ query if you'd like.
The inner loop goes over the values of the enum, and uses GetName to match the string to the value.