PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
C# | 109 lines | 97 code | 12 blank | 0 comment | 8 complexity | b9d512dd79250b83c7e65ad42c6d13bf 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.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Threading;
  7. internal class ContextViewModel : INotifyPropertyChanged
  8. {
  9. private BusinessLogicModel _businessLogicModel;
  10. private Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextData _contextData;
  11. private List<EntityViewModel> _entities;
  12. public event PropertyChangedEventHandler PropertyChanged;
  13. public ContextViewModel(BusinessLogicModel businessLogicModel, Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextData contextData)
  14. {
  15. this._businessLogicModel = businessLogicModel;
  16. this._contextData = contextData;
  17. }
  18. internal void EntityStateChanged()
  19. {
  20. this.RaisePropertyChanged("IsMetadataClassGenerationAllowed");
  21. this.RaisePropertyChanged("IsMetadataClassGenerationRequested");
  22. }
  23. private void RaisePropertyChanged(string propertyName)
  24. {
  25. if (this.PropertyChanged != null)
  26. {
  27. this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  28. }
  29. }
  30. public override string ToString()
  31. {
  32. return this.Name;
  33. }
  34. public Microsoft.VisualStudio.ServiceModel.DomainServices.Tools.ContextData ContextData
  35. {
  36. get
  37. {
  38. return this._contextData;
  39. }
  40. }
  41. public IEnumerable<EntityViewModel> Entities
  42. {
  43. get
  44. {
  45. if (this._entities == null)
  46. {
  47. EntityData[] entityDataItemsForContext = this._businessLogicModel.GetEntityDataItemsForContext(this.ContextData);
  48. this._entities = new List<EntityViewModel>();
  49. foreach (EntityData data in entityDataItemsForContext)
  50. {
  51. EntityViewModel item = new EntityViewModel(this, data);
  52. this._entities.Add(item);
  53. }
  54. this._entities.Sort((Comparison<EntityViewModel>) ((x, y) => string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase)));
  55. }
  56. return this._entities;
  57. }
  58. }
  59. public bool IsClientAccessEnabled
  60. {
  61. get
  62. {
  63. return this.ContextData.IsClientAccessEnabled;
  64. }
  65. set
  66. {
  67. if (value != this.ContextData.IsClientAccessEnabled)
  68. {
  69. this.ContextData.IsClientAccessEnabled = value;
  70. this.RaisePropertyChanged("IsClientAccessEnabled");
  71. }
  72. }
  73. }
  74. public bool IsODataEndpointEnabled
  75. {
  76. get
  77. {
  78. return this.ContextData.IsODataEndpointEnabled;
  79. }
  80. set
  81. {
  82. if (value != this.ContextData.IsODataEndpointEnabled)
  83. {
  84. this.ContextData.IsODataEndpointEnabled = value;
  85. this.RaisePropertyChanged("IsODataEndpointEnabled");
  86. }
  87. }
  88. }
  89. public string Name
  90. {
  91. get
  92. {
  93. return this.ContextData.Name;
  94. }
  95. }
  96. }
  97. }