Posted By


ak98 on 01/14/11

Tagged


Statistics


Viewed 99 times
Favorited by 0 user(s)

Related snippets


ViewModelLocator property


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. private static [[ViewModelType]] [[_viewModelPropertyName]];
  2.  
  3. /// <summary>
  4. /// Gets the [[ViewModelPropertyName]] property.
  5. /// </summary>
  6. public static [[ViewModelType]] [[ViewModelPropertyName]]Static
  7. {
  8. get
  9. {
  10. if (]]_viewModelPropertyName]] == null)
  11. {
  12. Create]]ViewModelPropertyName]]();
  13. }
  14.  
  15. return [[_viewModelPropertyName]];
  16. }
  17. }
  18.  
  19. /// <summary>
  20. /// Gets the [[ViewModelPropertyName]] property.
  21. /// </summary>
  22. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
  23. "CA1822:MarkMembersAsStatic",
  24. Justification = "This non-static member is needed for data binding purposes.")]
  25. public [[ViewModelType]] [[ViewModelPropertyName]]
  26. {
  27. get
  28. {
  29. return [[ViewModelPropertyName]]Static;
  30. }
  31. }
  32.  
  33. /// <summary>
  34. /// Provides a deterministic way to delete the [[ViewModelPropertyName]] property.
  35. /// </summary>
  36. public static void Clear]]ViewModelPropertyName]]()
  37. {
  38. [[_viewModelPropertyName]].Cleanup();
  39. [[_viewModelPropertyName]] = null;
  40. }
  41.  
  42. /// <summary>
  43. /// Provides a deterministic way to create the [[ViewModelPropertyName]] property.
  44. /// </summary>
  45. public static void Create]]ViewModelPropertyName]]()
  46. {
  47. if (]]_viewModelPropertyName]] == null)
  48. {
  49. [[_viewModelPropertyName]] = new [[ViewModelType]]();
  50. }
  51. }
  52.  
  53. /// <summary>
  54. /// Cleans up all the resources.
  55. /// </summary>
  56. public static void Cleanup()
  57. {
  58. Clear]]ViewModelPropertyName]]();
  59. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.