PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/SolutionFramework/Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.10.0/Microsoft/VisualStudio/ServiceModel/DomainServices/Tools/EntityViewModel.cs

#
C# | 111 lines | 98 code | 13 blank | 0 comment | 11 complexity | c20c7057d1936bd98ea4073a483ec574 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0
  1. namespace Microsoft.VisualStudio.ServiceModel.DomainServices.Tools
  2. {
  3. using System;
  4. using System.ComponentModel;
  5. using System.Threading;
  6. internal class EntityViewModel : INotifyPropertyChanged
  7. {
  8. private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel _contextViewModel;
  9. private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData _entityData;
  10. public event PropertyChangedEventHandler PropertyChanged;
  11. public EntityViewModel(Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel contextViewModel, Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData entityData)
  12. {
  13. this._contextViewModel = contextViewModel;
  14. this._entityData = entityData;
  15. }
  16. private void RaisePropertyChanged(string propertyName)
  17. {
  18. if (this.PropertyChanged != null)
  19. {
  20. this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  21. }
  22. this.ContextViewModel.EntityStateChanged();
  23. }
  24. public override string ToString()
  25. {
  26. return this.Name;
  27. }
  28. public bool CanBeEdited
  29. {
  30. get
  31. {
  32. return this.EntityData.CanBeEdited;
  33. }
  34. }
  35. public bool CanBeIncluded
  36. {
  37. get
  38. {
  39. return this.EntityData.CanBeIncluded;
  40. }
  41. }
  42. public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextViewModel ContextViewModel
  43. {
  44. get
  45. {
  46. return this._contextViewModel;
  47. }
  48. }
  49. public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.EntityData EntityData
  50. {
  51. get
  52. {
  53. return this._entityData;
  54. }
  55. }
  56. public bool IsEditable
  57. {
  58. get
  59. {
  60. return (this.EntityData.IsEditable && this.EntityData.CanBeEdited);
  61. }
  62. set
  63. {
  64. if ((value != this.EntityData.IsEditable) && (!value || this.EntityData.CanBeEdited))
  65. {
  66. this.EntityData.IsEditable = value;
  67. this.RaisePropertyChanged("IsEditable");
  68. if (value)
  69. {
  70. this.IsIncluded = true;
  71. }
  72. }
  73. }
  74. }
  75. public bool IsIncluded
  76. {
  77. get
  78. {
  79. return (this.EntityData.IsIncluded && this.EntityData.CanBeIncluded);
  80. }
  81. set
  82. {
  83. if (this.EntityData.IsIncluded != value)
  84. {
  85. this.EntityData.IsIncluded = value;
  86. this.RaisePropertyChanged("IsIncluded");
  87. }
  88. }
  89. }
  90. public string Name
  91. {
  92. get
  93. {
  94. return this.EntityData.Name;
  95. }
  96. }
  97. }
  98. }