sethballantyne / Plexis

A Breakout clone written in C++/CLI using DirectX 8, complete with level editor written in C#.
MIT License
2 stars 0 forks source link

Remove duplicate code from methods in EntityManager #112

Closed sethballantyne closed 4 years ago

sethballantyne commented 4 years ago

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.