// // GET: /Clone/ // // Home page for documents created using the Clone pattern // public IActionResult Index(string format) { // get a document that can be cloned (in a real program, this document would be passed to us by someone else) IDocument doc = DocumentCreatorSingleton.GetInstance().GetSampleDocument(format); // make a clone IDocument clone = doc.Clone(); return(View("~/Views/Shared/Results.cshtml", clone.GetString())); }
// // GET: /AbstractFactory/Submit // // Process a submission. // public IActionResult Submit(string format, string headingText, string paragraphText) { // get the proper document factory for the output type IDocumentFactory factory = DocumentCreatorSingleton.GetInstance().GetDocumentFactory(format); // create the document parts IHeading headingObj = factory.CreateHeading(1, headingText); IParagraph paragraphObj = factory.CreateParagraph(paragraphText); return(View("~/Views/Shared/Results.cshtml", headingObj.GetString() + paragraphObj.GetString())); }
// // GET: /AbstractFactory/Submit // // Process a submission. // public IActionResult Submit(string format, string titleText, string authorText, string bodyText) { // get the proper document builder for the output type IDocumentBuilder builder = DocumentCreatorSingleton.GetInstance().GetDocumentBuilder(format); // start building builder.OpenDocument(); // build the head with the title and author builder.BuildHead(titleText, authorText); // build the body builder.BuildBody(bodyText); // finished building builder.CloseDocument(); return(View("~/Views/Shared/Results.cshtml", builder.GetDocument().GetString())); }