mrkarp

HTMLManager.cs

Dec 28th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp1.HTML
  9. {
  10. class HTMLManager
  11. {
  12. public string CreateHTML(string templateHTML, string[] userNameArray)
  13. {
  14. string html = File.ReadAllText(templateHTML);
  15. html = html.Replace("{USERARRAY}", UserHTML(userNameArray));
  16. html = html.Replace("{USERSUM}", userNameArray.Length.ToString());
  17.  
  18. //File.WriteAllText("test.txt", text);
  19. Console.WriteLine("HTML Composed");
  20. return html;
  21.  
  22. }
  23.  
  24. private string UserHTML(string[] userNameArray)
  25. {
  26. string userHTML = "";
  27. List<string> userNames = new List<string>();
  28. for(int i = 0; i < userNameArray.Length; i++)
  29. {
  30. userNames.Add("<tr>" +
  31. "<td>" + userNameArray[i] + "</td>" +
  32. "<td>" + userNameArray[i] + "</td>" +
  33. "</tr>" + "\n");
  34. }
  35.  
  36. userHTML = string.Join("", userNames);
  37. Console.WriteLine("UserHTML Complete");
  38. return userHTML;
  39. }
  40.  
  41. }
  42. }
Add Comment
Please, Sign In to add comment