///////////////////////////////////////////////////////////// // Subsystem2.cpp - Part of Facade Skeleton Demo // // // // Jim Fawcett, CSE776 - Design Patterns, Summer 2009 // ///////////////////////////////////////////////////////////// #using #using using namespace System; using namespace System::Text; using namespace System::Xml; using namespace System::Windows::Forms; #include "Subsystem2.h" #include //----< announce self >-------------------------------------- String^ Subsystem2::say(String^ msg) { System::Windows::Forms::MessageBox::Show(msg, "Subsystem2"); return msg; } //----< save output in xml file and send to console >-------- void Subsystem2::save(String^ msg) { XmlDocument^ doc = gcnew XmlDocument(); XmlNode^ Decl = doc->CreateXmlDeclaration("1.0", "Utf-16", ""); doc->AppendChild(Decl); XmlElement^ Node = doc->CreateElement("output"); String^ temp = msg + "\n some very important output from Subsystem2"; XmlNode^ text = doc->CreateTextNode(temp); Node->AppendChild(text); doc->AppendChild(Node); doc->Save("Facade-Subsystem2.output.xml"); String^ output = doc->ToString(); Console::Write("\n {0}\n\n",output); } //----< convert std::string to System::String >-------------- String^ ConvertString(const std::string& str) { std::wstring wstr; for(size_t i=0; i---------------------------------------- void main(int argc, char* argv[]) { Subsystem2 ss2; std::string temp; if(argc == 1) temp = "no message from Facade"; else temp = argv[1]; ss2.save(ss2.say(ConvertString(temp))); Console::Write("\nPress key to quit: "); Console::ReadKey(); }