Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Text
Posted by: Logan Laughlin
Added: Feb 5, 2020 5:08 PM
Modified: Feb 5, 2020 5:09 PM
Views: 139
  1. ## ViewModel Property Replacement
  2.  
  3. >
  4. > ``` cs
  5. > set
  6. > {
  7. >   _field = value;
  8. >   RaisePropertyChanged();
  9. > }
  10. >  ```
  11. >
  12. > ``` regexp
  13. > set\s*\{\s*(_\w*)\s*=\s*value;\s*RaisePropertyChanged\(.*\);\s*}
  14. > set => Set\(ref $1, value\);
  15. > ```
  16.  
  17. ---
  18. > ``` cs
  19. > set
  20. > {
  21. >   Set(ref _field , value);
  22. >   RaisePropertyChanged();
  23. > }
  24. > ```
  25. > ``` regexp
  26. > set\s*\{\s*Set\(ref\s+(_\w*)\s*,\s*value\);\s*RaisePropertyChanged\(\);\s*}
  27. > set => Set\(ref $1, value\);
  28. > ```
  29. ---
  30. > ``` cs
  31. > set
  32. > {
  33. >   _field = value;
  34. >   RaisePropertyChanged();
  35. >   RaisePropertyChanged("OtherProperty");
  36. > }
  37. > ```
  38. >
  39. > ``` regexp
  40. > set(\s*\{\s*)(_\w*)\s*=\s*value;\s*RaisePropertyChanged\(\);(\s*.*\s*)\s*}
  41. > set$1Set\(ref $2, value\);$3}
  42. > ```
  43. ---
  44. > ``` cs
  45. > RaisePropertyChanged(() => PropertyName);
  46. > ```
  47. >
  48. > ``` regexp
  49. > RaisePropertyChanged\(\(\) => (\w*)\);
  50. > RaisePropertyChanged(nameof($1));
  51. ---
  52. > ``` cs
  53. > _field = value;
  54. > RaisePropertyChanged();
  55. > ```
  56. >
  57. > ``` regexp
  58. > (_\w*)\s*=\s*value;\s*RaisePropertyChanged\(.*\);
  59. > Set\(ref $1, value\);
  60.  
  61.  
  62. ## Localizer.Resolve Replacement
  63.  
  64. > ``` cs
  65. > Localizer.Resolve("SystemHealth:ServiceStatus")
  66. > ```
  67. > ``` regexp
  68. > Localizer.Resolve\("(\w*):(\w*)"\)
  69. > $1.$2
  70. > ```
  71.  
  72. ## string.IsNullOrEmpty replacements
  73.  
  74. > ``` cs
  75. > string.IsNullOrEmpty(str)
  76. > ```
  77. > ``` regexp
  78. > string.IsNullOrEmpty\((\w*)\)
  79. > $1.HasValue()
  80. > ```
  81.  
  82. > ``` cs
  83. > !string.IsNullOrEmpty(str)
  84. > ```
  85. > ``` regexp
  86. > !string.IsNullOrEmpty\((\w*)\)
  87. > $1.IsEmpty()
  88. > ```
  89.  
  90. ## ServiceLocator GetInstance to Getter Property
  91.  
  92. > ``` cs
  93. > ServiceLocator.Current.GetInstance<IDiagnosticsManager>()
  94. > ```
  95. > ``` regexp
  96. > ServiceLocator\.Current\.GetInstance<I(\w*)>\(\)
  97. > $1
  98. > ```
  99.  
  100.  
  101. ## Reference to PackageReference Replacement
  102. ``` regexp
  103. <Reference Include="(.*?), Version=(.*?),(.*\n)*?\s+</Reference>
  104. <PackageReference Include="$1" Version="$2" />
  105. ```
  106.  
  107. ## PAssert replacements
  108.  
  109. ``` regexp
  110. Assert.IsNotNull\((.*?)\);
  111. PAssert.That(() => $1 != null);
  112. ```
  113.  
  114. ``` regexp
  115. Assert.IsTrue\((.*?)\);
  116. PAssert.That(() => $1 == true);
  117. ```
  118.  
  119.  
  120. ``` regexp
  121. Assert.AreEqual\((.*?), (.*?)\);
  122. PAssert.That(() => $2 == $1);
  123. ```
  124.