Guest User

Untitled

a guest
Apr 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using SharpSvn;
  2. using Flurl;
  3.  
  4. static readonly string reposRootString = @"https://my.svn.repos/Testing/";
  5. static readonly string vendor = "Vendor";
  6. static readonly string driver = "Driver+";
  7. static readonly string version = "1.0.0.1";
  8.  
  9. static void Main(string[] args)
  10. {
  11. DoDontEscape();
  12. DoEscape();
  13.  
  14. }
  15.  
  16. private static void DoDontEscape()
  17. {
  18. string combined = Url.Combine(reposRootString, vendor, driver, version);
  19. TryCreateURI(combined);
  20. }
  21.  
  22. private static void DoEscape()
  23. {
  24. var vEscaped = Uri.EscapeDataString(vendor);
  25. var dEscaped = Uri.EscapeDataString(driver);
  26. var dvEscaped = Uri.EscapeDataString(version);
  27.  
  28. string combined = Url.Combine(reposRootString, vEscaped, dEscaped, dvEscaped);
  29. TryCreateURI(combined);
  30. }
  31.  
  32. private static void TryCreateURI(string combined)
  33. {
  34. Uri uri;
  35. if (Uri.TryCreate(combined, UriKind.Absolute, out uri))
  36. {
  37. CreateSvnDir(uri);
  38. }
  39. else
  40. {
  41. throw new Exception(string.Format("{0} is an invalid URI!", combined));
  42. }
  43. }
  44.  
  45. private static void CreateSvnDir(Uri uri)
  46. {
  47. using (SvnClient client = new SvnClient())
  48. client.RemoteCreateDirectory(uri, new SvnCreateDirectoryArgs() { CreateParents = true, LogMessage = "create dir" });
  49. }
Add Comment
Please, Sign In to add comment