A lot of the parse methods contain the chunk of code
`
System::Collections::Generic::IEnumerable<XElement ^> ^frameQuery = powerupElement->Elements((String ^) "frame");
if(0 == XmlHelper::Count(frameQuery))
{
throw gcnew XmlException(String::Format("powerup {0} doesn't have any frames associated with it.", name));
}
List<Frame ^> ^frames = gcnew List<Frame ^>();
for each(XElement ^frameElement in frameQuery)
{
frames->Add(ParseFrame(frameElement));
}
`
The only thing that differs is the error message; chuck it all into a seperate function and pass the error message as an argument.
A lot of the parse methods contain the chunk of code ` System::Collections::Generic::IEnumerable<XElement ^> ^frameQuery = powerupElement->Elements((String ^) "frame"); if(0 == XmlHelper::Count(frameQuery)) { throw gcnew XmlException(String::Format("powerup {0} doesn't have any frames associated with it.", name)); }
` The only thing that differs is the error message; chuck it all into a seperate function and pass the error message as an argument.