Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. namespace CommonLNG.Resources
  2. {
  3. public static class Strings
  4. {
  5. public class StringChain
  6. {
  7. private StringChain mRequest;
  8. public StringChain Request => mRequest ?? (mRequest = new StringChain("Request", this));
  9.  
  10. private StringChain mResult;
  11. public StringChain Result => mResult ?? (mResult = new StringChain("Result", this));
  12.  
  13. private StringChain mCreate;
  14. public StringChain Create => mCreate ?? (mCreate = new StringChain("Create", this));
  15.  
  16. private StringChain mDestroy;
  17. public StringChain Destroy => mDestroy ?? (mDestroy = new StringChain("Destroy", this));
  18.  
  19. private StringChain mDirectory;
  20. public StringChain Directory => mDirectory ?? (mDirectory = new StringChain("Directory", this));
  21.  
  22. private StringChain mFile;
  23. public StringChain File => mFile ?? (mFile = new StringChain("File", this));
  24.  
  25. private string Text { get; }
  26. private StringChain Parent { get; set; }
  27.  
  28. public StringChain(string text = "", StringChain parent = null)
  29. {
  30. Text = text;
  31. Parent = parent;
  32. }
  33.  
  34. public static implicit operator string(StringChain v)
  35. {
  36. var result = "";
  37. while (v != null)
  38. {
  39. result = $".{v.Text}{result}";
  40. v = v.Parent;
  41. }
  42. while (result.StartsWith("."))
  43. result = result.Substring(1);
  44. return result;
  45. }
  46.  
  47. public bool IsMe(string category)
  48. {
  49. return category.Contains($".{Text}") || category.Contains($"{Text}.");
  50. }
  51. }
  52.  
  53. public static StringChain Root { get; } = new StringChain();
  54.  
  55. public static string RequestCreateDirectoryCategory = Root.Request.Create.Directory;
  56. public static string RequestCreateFileCategory = Root.Request.Create.File;
  57.  
  58. public static string RequestDeleteDirectoryCategory = Root.Request.Destroy.Directory;
  59. public static string RequestDeleteFileCategory = Root.Request.Destroy.File;
  60.  
  61. public static string ResultCreateDirectoryCategory = Root.Result.Create.Directory;
  62. public static string ResultCreateFileCategory = Root.Result.Create.File;
  63.  
  64. public static string ResultDeleteDirectoryCategory = Root.Result.Destroy.Directory;
  65. public static string ResultDeleteFileCategory = Root.Result.Destroy.File;
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement